Bonjour tout le monde,
J'essaie de réaliser une page d'authentification en PHP.
J'ai développé l'interface graphique en CSS et maintenant j'essaie d'intégrer un fichier en PHP.
La partie concernée de ma pahe HTML est la suivante:
le fichier qui assure la connexion à la base et la vérification des données est members.php, le contenu est le suivant:
Code html : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30 <!-- page "login in" --> <div id="login" class="animate form"> <form action="members.php" autocomplete="on"> <!-- appel du fichier members.php --> <h1>Log in</h1> <p> <label for="username" class="uname" data-icon="u" > Username </label> <input id="username" name="username" required="required" type="text" placeholder="example mymail@mail.com"/> </p> <p> <label for="password" class="youpasswd" data-icon="p"> Password </label> <input id="password" name="password" required="required" type="password" placeholder="example mypassword"/> </p> <p class="keeplogin"> <input type="checkbox" name="loginkeeping" id="loginkeeping" value="loginkeeping" /> <label for="loginkeeping">Keep me logged in</label> </p> <p class="login button"> <input type="submit" value="Login" /> </p> <p class="change_link"> Not a member yet ? <a href="#toregister" class="to_register">Register</a> </p> </form> </div>
mais je n'arrive pas à le faire fonctionner j'ai toujours l'erreur "Go back and login before you visit this page!"!!
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76 <?php //STEP 1 Connect To Database $connect = mysql_connect('localhost','root','Orange2424'); if (!$connect) { die("MySQL could not connect!"); } $DB = mysql_select_db('OrangeTunisie'); if(!$DB) { die("MySQL could not select Database!"); } //STEP 2 Declare Variables $Name = $_POST['username']; $Pass = $_POST['password']; $Query = mysql_query("SELECT * FROM Authentication WHERE Username='$Name' AND Password='$Pass'"); $NumRows = mysql_num_rows($Query); $_SESSION['username'] = $Name; $_SESSION['password'] = $Pass; //STEP 3 Check to See If User Entered All Of The Information if(empty($_SESSION['username']) || empty($_SESSION['password'])) { die("Go back and login before you visit this page!"); } if($Name && $Pass == "") { die("Please enter in a name and password!"); } if($Name == "") { die("Please enter your name!" . "</br>"); } if($Pass == "") { die("Please enter a password!"); echo "</br>"; } //STEP 4 Check Username And Password With The MySQL Database if($NumRows != 0) { while($Row = mysql_fetch_assoc($Query)) { $Database_Name = $Row['username']; $Database_Pass = $Row['password']; } } else { die("Incorrect Username or Password!"); } if($Name == $Database_Name && $Pass == $Database_Pass) { // If The User Makes It Here Then That Means He Logged In Successfully echo "Hello " . $_SESSION['username'] . "!"; } ?> <html> <body> <p>Here is where you can put information for the user to see when he logs on. (Anything inside these html tags!)</p> </body> </html>
merci d'avance pour votre aide
Partager