session_start();
if(isset($_SESSION['logged'])){
header('Location: esm_questionnaire.php');
}
if(isset($_POST['utilisateur'])&&isset($_POST['motdepasse'])){
$con = mysql_connect('localhost','root','');
mysql_select_db('esm_quiz', $con);
$datID = mysql_real_escape_string($_POST['utilisateur']);
$datPASS = $_POST['motdepasse'];
$datPASS = hash(sha512, $datPASS);
$SQL = "SELECT * FROM esm_sujets WHERE code_exp = '$datID'";
$result = mysql_query($SQL, $con);
$row = mysql_fetch_array($result);
if($result){
if($datPASS === $row['pass_exp']){
$_SESSION['logged'] = true;
$_SESSION['sexe'] = $row['sexe'];
$_SESSION['type'] = $row['type_attachement'];
header('Location: esm_questionnaire.php');
}
else{
die('Vous n'avez pas acces');
}
}
}
注意:使用未定义的常量 sha512 - 在第 12 行的 C:\wamp\www\Nouveaudossier\esm_connexion.php 中假定为“sha512”
如果我的密码或用户名错误,这是我得到的错误