所以,我试图创建一个帐户确认,但它没有工作。
这是登录页面,它应该检查帐户何时被激活,但即使数据已在数据库中确认,它始终显示它未被激活,因此它始终显示未激活的消息。
if(isset($_POST['login_button']))
{
$userName = $_POST['username'];
$userPass = $_POST['password'];
$hashedPass = hash('whirlpool', $userPass);
$query = "SELECT Ime FROM Igraci WHERE Ime = '$userName' AND Lozinka = '$hashedPass'";
$stmt = mysqli_prepare($con, $query) or die(mysqli_error($con));
mysqli_stmt_bind_param($stmt, "ss", $userName, $hashedPass);
mysqli_stmt_execute($stmt);
$result = mysqli_stmt_get_result($stmt);
$row = mysqli_fetch_array($result);
while($conf = mysqli_fetch_assoc(query))
{
$aktiviran = $conf['Confirmed'];
}
if($row)
{
if($aktiviran == 1)
{
$session = md5($userName.$hashedPass);
mysqli_query($con, "UPDATE Igraci SET session = '$session' WHERE Ime = '$userName' AND Lozinka = '$hashedPass'");
setcookie("username", $_POST['username'], time()+3600*24);
setcookie("authorization","ok");
header( "Location:welcome.php");
exit();
}
else
{
echo '
<div class="transbox" position = "center">
<center><p>Ovaj racun nije aktiviran, molimo da ga aktivirate.</p>
<p>Ukoliko niste primili email proverite junk folder ili ponovo zatrazite aktivaciju racuna.</p>
</center>
</div>
';
}
}
答案 0 :(得分:0)
试试这样:
if($row) {
if($row[number of the column 'Confirmed']==1) {
// do the stuff
} else {
// do the other stuff
}
}
这样你就不会需要while()和fetch_assoc()(返回null)