Reputation: 95
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');
}
}
}
Notice: Use of undefined constant sha512 - assumed 'sha512' in C:\wamp\www\Nouveaudossier\esm_connexion.php on line 12
this is the error i get if i have a wrong password or username
Upvotes: 1
Views: 378
Reputation: 3204
$datPASS = hash(sha512, $datPASS);
Replace it with
$datPASS = hash("sha512", $datPASS);
It will run eitherway though, lucky PHP is intelligent enough.
Upvotes: 0
Reputation: 14302
It needs to change from:
$datPASS = hash(sha512, $datPASS);
To
$datPASS = hash('sha512', $datPASS);
OR, you need to define sha512
as a constant first:
define('sha512', 'sha512');
But that seems a little silly, doesn't it?
Upvotes: 1