multi session avec else if et mysql
Bonjour,
Avec ce script j'arrivé à acceder à la page home1.php et home2.php, mon probleme est je ne peux pas j'accède au home3.php
DB
Code:
1 2 3 4 5 6
| CREATE TABLE IF NOT EXISTS `user` (
`id` int(11) NOT NULL,
`email` varchar(25) NOT NULL,
`pw` varchar(10) NOT NULL,
`profil` varchar(2) NOT NULL
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf32; |
login_form.html
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<form action="login_action.php" method="post">
<p>
email :
<input name="email" type="text" />
</p>
<p>
mot de passe : <input name="pw" type="text" />
</p>
<p>
<input name="submit" type="submit" />
</p>
</form>
</body>
</html> |
login_action.php:
Code:
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
| <?php
session_start();
$_SESSION['email'] = '';
$_SESSION['pw'] = '';
include_once("connection.php");
if (isset($_POST['submit'])){
$login = $_POST['email'];
$pass = $_POST['pw'];
$_SESSION['email'] = "$login";
$_SESSION['pw'] = "$pass";
$resultat = mysql_query("select email,pw,profil from user where email='$login' AND pw='$pass'");
while ($row = mysql_fetch_array($resultat, MYSQL_ASSOC)){
$profil = $row['profil'];
$dbusername = $row['pw'];
$email = $row['email'];
if(($dbusername == $pass) && ($email == $login)&&($profil == 20)){
header("location:home1.php");
}
elseif(($dbusername == $pass) && ($email == $login)&&($profil == 10)){
header("location:home2.php");
}
else {
header("location:home3.php");
}
}
}
else {die ("erreur");}
?> |
Merci.