Merci pour vos conseils, maintenant j'ai un autre soucis au niveau du session_start()
Voici mon code et mon erreur qui s'affiche :
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 77 78 79 80 81 82 83 84
| <?php
session_start();
if (!empty($_POST['Submit'])) {
switch($_POST['Submit']) {
// Se délogger
case "Déconnecter" :
$_SESSION = array();
session_destroy();
echo "Vous êtes déconnecté !<br />";
break;
// Se logger
case "Connecter" :
if(isset($_POST) && !empty($_POST['login']) && !empty($_POST['pass'])){
extract($_POST);
$pass = sha1($pass);
mysql_connect("sql5.power-heberg.net","frenezikteam","ev9celjk");
mysql_select_db("Login");
$sql = " SELECT id,role FROM user WHERE login='$login' AND pass='$pass'";
$req = mysql_query($sql) or die(mysql_error());
if (mysql_num_rows($req)>0) {
$data = mysql_fetch_assoc($req);
$_SESSION['Auth'] = array(
'login' => $login,
'pass' => $pass,
'role' => $data['role']
);
mysql_query("UPDATE user SET last_connection = NOW() WHERE id='".$data['id']."'");
} else {
echo "Mauvais identifiants !<br />";
}
}
if($login == "Administrator"){
echo " Administration";
}
break;
// Default
//default:
}
}
// Si loggé
if (!empty($_SESSION['Auth'])) {
echo "Bienvenue <b><u>".$_SESSION['Auth']['login']."</u></b> !<br >Vous êtes connecté en tant que ".$_SESSION['Auth']['role'].".<br /><br />
<a href='account.php'class='gras' >Accéder à la page Account</a><br /><br />
<form method='POST' action='log/logout.php'><input type='submit' name='Submit' value='Déconnecter' /></form>";
} else {
// Si pas loggé
?><!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=UTF-8" />
<title>Ma page</title>
</head>
<body>
<form action="index.php" method="post">
Login : <br /><input type="text" name="login"/><br/>
Mot de pass : <br /><input type="password" name="pass"/><br/>
<input type="submit" name="Submit" value="Connecter" />
</form><br />
<a href="create.php">Se créer un compte</a>
</body>
</html>
<?php
}
?> |
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/frenezikteam/www/index.php:8) in /home/frenezikteam/www/log/login_2.php on line 2
Quelqu'un pour m'aider svp ?
Partager