Inscription, authentification > en .txt > facile

Contenu du snippet

Voila ici vous trouverez le necessaire pour faire une inscription et une authentification simple et efficace en .txt
n oubliez pas qu il faut vous creer 3 fichiers, un qui stock les pseudo(membre.txt), un les pqssword(password.txt), et l autre les informations personnels...(listnews.dat)

Source / Exemple :


dans inscription.html : 

<html>
<body>
      <h5 align="center"><font color="#99CCFF" size="2" face="Verdana, Arial, Helvetica, sans-serif"><font color="000000" size="1">Informations général
</h5>
<br>
<p align="left">
<form method="post" action="valid.php">
<font color="ff0000">*</font>Votre pseudo: <input type="text" name="pseudo" id="pseudo" size="12" style="BACKGROUND-COLOR: #ffffff; BORDER-BOTTOM: #000000 1px solid; BORDER-LEFT: #000000 1px solid; BORDER-RIGHT: #000000 1px solid; BORDER-TOP: #000000 1px solid; COLOR: #000080; CURSOR: text; FONT-FAMILY: Arial; FONT-SIZE: 7pt; FONT-WEIGHT:bold; LETTER-SPACING: normal; WIDTH:110; TEXT-ALIGN=center;"><br>
<font color="ff0000">*</font>Adresse E-mail: <input type="text" name="mail" id="email" size="12" style="BACKGROUND-COLOR: #ffffff; BORDER-BOTTOM: #000000 1px solid; BORDER-LEFT: #000000 1px solid; BORDER-RIGHT: #000000 1px solid; BORDER-TOP: #000000 1px solid; COLOR: #000080; CURSOR: text; FONT-FAMILY: Arial; FONT-SIZE: 7pt; FONT-WEIGHT:bold; LETTER-SPACING: normal; WIDTH:110; TEXT-ALIGN=center;"><br>
<font color="ff0000">*</font>Mot de passe: <input type="text" name="password" id="password" size="12" style="BACKGROUND-COLOR: #ffffff; BORDER-BOTTOM: #000000 1px solid; BORDER-LEFT: #000000 1px solid; BORDER-RIGHT: #000000 1px solid; BORDER-TOP: #000000 1px solid; COLOR: #000080; CURSOR: text; FONT-FAMILY: Arial; FONT-SIZE: 7pt; FONT-WEIGHT:bold; LETTER-SPACING: normal; WIDTH:70; TEXT-ALIGN=center;"><br>
</p>
<br><br>
      <h5 align="center"><font color="#99CCFF" size="2" face="Verdana, Arial, Helvetica, sans-serif"><font color="000000" size="1">Informations personnel
</h5>
<br>
<p align="left">
<font color="ff0000">*</font>chan de votre clan: <input type="text" id="cc" name="cc" size="12" style="BACKGROUND-COLOR: #ffffff; BORDER-BOTTOM: #000000 1px solid; BORDER-LEFT: #000000 1px solid; BORDER-RIGHT: #000000 1px solid; BORDER-TOP: #000000 1px solid; COLOR: #000080; CURSOR: text; FONT-FAMILY: Arial; FONT-SIZE: 7pt; FONT-WEIGHT:bold; LETTER-SPACING: normal; WIDTH:110; TEXT-ALIGN=center;"><br>
<font color="ff0000">*</font>site web de votre clan: <input type="text" id="swc" name="swc" size="12" style="BACKGROUND-COLOR: #ffffff; BORDER-BOTTOM: #000000 1px solid; BORDER-LEFT: #000000 1px solid; BORDER-RIGHT: #000000 1px solid; BORDER-TOP: #000000 1px solid; COLOR: #000080; CURSOR: text; FONT-FAMILY: Arial; FONT-SIZE: 7pt; FONT-WEIGHT:bold; LETTER-SPACING: normal; WIDTH:110; TEXT-ALIGN=center;"><br>
<font color="ff0000">*</font>Votre age: <input type="text" name="age" sid="age" ize="12" style="BACKGROUND-COLOR: #ffffff; BORDER-BOTTOM: #000000 1px solid; BORDER-LEFT: #000000 1px solid; BORDER-RIGHT: #000000 1px solid; BORDER-TOP: #000000 1px solid; COLOR: #000080; CURSOR: text; FONT-FAMILY: Arial; FONT-SIZE: 7pt; FONT-WEIGHT:bold; LETTER-SPACING: normal; WIDTH:30; TEXT-ALIGN=center;"><br>
<font color="ff0000">*</font>Numero de telephone: <input type="text" id="nt" name="nt" size="12" style="BACKGROUND-COLOR: #ffffff; BORDER-BOTTOM: #000000 1px solid; BORDER-LEFT: #000000 1px solid; BORDER-RIGHT: #000000 1px solid; BORDER-TOP: #000000 1px solid; COLOR: #000080; CURSOR: text; FONT-FAMILY: Arial; FONT-SIZE: 7pt; FONT-WEIGHT:bold; LETTER-SPACING: normal; WIDTH:110; TEXT-ALIGN=center;"><br>
<font color="ff0000">*</font>Prenom: <input type="text" name="prenom" id="prenom" size="12" style="BACKGROUND-COLOR: #ffffff; BORDER-BOTTOM: #000000 1px solid; BORDER-LEFT: #000000 1px solid; BORDER-RIGHT: #000000 1px solid; BORDER-TOP: #000000 1px solid; COLOR: #000080; CURSOR: text; FONT-FAMILY: Arial; FONT-SIZE: 7pt; FONT-WEIGHT:bold; LETTER-SPACING: normal; WIDTH:110; TEXT-ALIGN=center;"><br>
<font color="ff0000">*</font>Nom: <input type="text" name="nom" size="12" id="nom" style="BACKGROUND-COLOR: #ffffff; BORDER-BOTTOM: #000000 1px solid; BORDER-LEFT: #000000 1px solid; BORDER-RIGHT: #000000 1px solid; BORDER-TOP: #000000 1px solid; COLOR: #000080; CURSOR: text; FONT-FAMILY: Arial; FONT-SIZE: 7pt; FONT-WEIGHT:bold; LETTER-SPACING: normal; WIDTH:110; TEXT-ALIGN=center;"><br>
<font color="ff0000">*</font>Adresse: <textarea name="adresse" id="adresse" rows=3 cols=20 style="BACKGROUND-COLOR: #ffffff; BORDER-BOTTOM: #000000 1px solid; BORDER-LEFT: #000000 1px solid; BORDER-RIGHT: #000000 1px solid; BORDER-TOP: #000000 1px solid; COLOR: #000080; CURSOR: text; FONT-FAMILY: Arial; FONT-SIZE: 7pt; FONT-WEIGHT:bold; LETTER-SPACING: normal;">
</textarea><br>
<font color="ff0000">*</font>Code postal: <input type="text" id="cp" name="cp" size="12" style="BACKGROUND-COLOR: #ffffff; BORDER-BOTTOM: #000000 1px solid; BORDER-LEFT: #000000 1px solid; BORDER-RIGHT: #000000 1px solid; BORDER-TOP: #000000 1px solid; COLOR: #000080; CURSOR: text; FONT-FAMILY: Arial; FONT-SIZE: 7pt; FONT-WEIGHT:bold; LETTER-SPACING: normal; WIDTH:50; TEXT-ALIGN=center;"><br>
<br>
<CENTER><input type="image" border="0" src="b_valider_bl.gif" width="67" height="14" name="valider"></CENTER>
            <input type="hidden" name="AdressRedirect" value="added.htm¤already.htm¤deleted.htm¤notexist.htm¤">
            <br>
            <input name="delete" type="checkbox" id="delete" value="true">
            Enlever cette adresse à la liste
            <input name="redir_already" type="hidden" id="redir_already" value="reponses/already.htm">
            <input name="redir_notfound" type="hidden" id="redir_notfound" value="reponses/notexist.htm">
            <input name="redir_deleted" type="hidden" id="redir_deleted" value="reponses/deleted.htm">
            <input name="redir_added" type="hidden" id="redir_added" value="reponses/added.htm">
            <input name="cat" type="hidden" id="cat" value="news">
            </p>
</form>
</font>
</body>
</html>
dans valid.php :

<?
	if (!file_exists("list".$cat.".dat")) { // Initialisation : Création du premier fichier de données 
		$f = fopen("list".$cat.".dat", "w+");
		fputs($f, "");
		fclose($f);
	} 
	// On vérifie si l'adresse existe déjà
	$data = file("list".$cat.".dat");
	foreach($data as $pos => $value) {
		$value=substr($value, 0, strlen($value) - 2);
		if ($mail==$value) {
			header("Location: ".$redir_already);
			die();
		}
	}
	$f = fopen("list".$cat.".dat", "a");
	$f2 = fopen("membre.txt", "a");
	$f3 = fopen("password.txt", "a");
	fputs($f, $pseudo."\n");
	fputs($f, $password."\n");
	fputs($f, $age."\n");
	fputs($f, $cc."\n");
	fputs($f, $prenom."\n");
	fputs($f, $nom."\n");
	fputs($f, $adresse."\n");
	fputs($f, $swc."\n");
	fputs($f, $cp."\n");
	fputs($f2, $pseudo."\n");
	fputs($f3, $password."\n");
	fclose($f);
	fclose($f2);
	fclose($f3);
	header("Location: ".$redir_added);
	die();		
}
?>//n oubliez pas qu il faut vous creer 3 fichiers, un qui stock les pseudo(membre.txt), un les pqssword(password.txt), et l autre les informations personnels...(listnews.dat)

autnetification :

<html>
<body> 
<form method="post" action="valid.php">
<input type="text" name="pseudo">
<input type="password" name="password">
</form>
</body>
</html>

dans test2.php : 

<?php

$temoin=0;
$var=file("membre.txt");//tableau des members
$var2=file("password.txt");//tableau des mots de pass
$numeroligne=0;
while($var[$numeroligne]!=""){//parcourir le tableau members jusqu a ""
	if($pseudo==trim($var[$numeroligne])){//si le login est dans la ligne en cours de lecture du tableau des members
			$temoin=1;
	if($password==trim($var2[$numeroligne]))
                        $temoin=$temoin+1;
	}
$numeroligne=$numeroligne+1;//complement de boucle
        }
if($temoin==0)// si temoin est egale a 0 alors le visiteur n'a rien entré, n y password n y pseudp
	include "index.php";//la page d erreure
if($temoin==1)// si temoin est egale a 1 alors le password est bon mais pas le password
	include "index.php";//la page d erreure
if($temoin==2)//si temoin est egale a 2 alors le password et pseudo sont bon !
        include "membre.php";//on dirige vers la page membre

?>

Conclusion :


bref a vous de rajoutez le script qui securise les page membres etc.. n esitez pas laissez vos impressions en dessous, si vous detectez des bug... :s

A voir également

Vous n'êtes pas encore membre ?

inscrivez-vous, c'est gratuit et ça prend moins d'une minute !

Les membres obtiennent plus de réponses que les utilisateurs anonymes.

Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.

Le fait d'être membre vous permet d'avoir des options supplémentaires.