Answer the question
In order to leave comments, you need to log in
Why doesn't function confirm change 0 to 1 in the database when confirming registration?
function confirm()
{
global $db;
$new_hash = clear_str($_GET['hash']);
$query = "UPDATE . PREF .`users` SET confirm = '1' WHERE `hash` = '%s'";
$query = sprintf($query, mysqli_real_escape_string($db, $new_hash));
$resutl = mysqli_query($db, $query);
if (mysqli_affected_rows($resutl) == 1) {
return TRUE;
} else {
return "Не верный код подтверждения регистрации";
}
}
?>
if($_GET['hash']) {
$confirm = confirm();
if($confirm === TRUE) {
$_SESSION['msg'] = "Ваша учетная запись активирована. Можете авторизироваться нга сайте.";
header("Location:".$_SERVER['PHP_SELF']);
exit();
}
}
else {
$_SESSION['msg'] = $msg;
header("Location:".$_SERVER['PHP_SELF']);
exit();
}
Answer the question
In order to leave comments, you need to log in
mysqli_affected_rows($db)
php.net/manual/ru/mysqli.affected-rows.php
I already found an error, I just deleted the name localhost from the link that comes to the mail.
But now the error
function confirm()
{
global $db;
$new_hash = clear_str($_GET['hash']);
$query = "UPDATE " . PREF . "users
SET confirm='1'
WHERE hash = '%s'
";
$query = sprintf($query, mysqli_real_escape_string($db,$new_hash));
$result = mysqli_query($db,$query);
if(mysqli_affected_rows() == 1){
return TRUE;
}
else {
return "Неверный код подтверждения регистрации";
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question