index.php
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
<html>
<body>
<form action="index.php" method="POST">
  <p>Username
    <input type="text" name="user"> 
  Password
  <input type="password" name="pwd">
  <input name="Submit" type="submit" value="OK">
<a href="inscription.php">vous n etes pas membre</a>
  </p>
</form>
 
<?php
if(isset($_POST["Submit"]))
{session_start();
session_destroy();
$username=$_POST["user"];
$password=$_POST["pwd"];
mysql_connect('localhost','root','');
mysql_select_db('compte'); 
$req=mysql_query("select * from utilisateur where username='$username' 
and password='$password'");
if(mysql_num_rows($req)!=0)
{session_register("username");
header("location:main.php");}
else
{echo "login incorrect";}
}
?> 
 
 
 
</body>
</html>
inscription.php
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
<html>
<body>
<form action="inscription.php" method="POST">
  <p>Username
    <input type="text" name="user"> 
  <p>Password
  <input type="password" name="pwd">
  <p>n°carte <input type="text" name="num">
  <input type="submit" name="Submit" value="OK">
</form>
<?php
if(isset($_POST["Submit"]))
{mysql_connect('localhost','root','');
mysql_select_db('compte');
$username=$_POST['user'];
$password=$_POST['pwd'];
$numero=$_POST['num'];
$sql="insert into utilisateur values('$username','$password','$numero')";
mysql_query($sql);
mysql_close();
header("location:index.php");
}
?>
</body>
</html>
main.php
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
<htm>
<body>
<?php
session_start();
if(!session_is_registered("username")){
header("location:index.php"); 
}else
{echo $_SESSION['username'];}
?>
your are logged in<br>         
<a href="index.php">logout</a>
</body>
</html>
quand je met mon login et je vais a main le nom de compte n affiche pas
je veux ajouter un bouton checkbox pour enregistrer le login
et aidez moi a ameliorer mon code svp