Answer the question
In order to leave comments, you need to log in
How to correctly write mysql_result to mysqli?
function login($post)
{
global $db;
if (empty($post['login']) || empty($post['password'])) {
return "Заполните поля";
}
$login = clear_str($post['login']);
$password = md5(trim($post['password']));
$sql = "SELECT user_id,confirm
FROM " . PREF . "users
WHERE login = '%s'
AND password = '%s'";
$sql = sprintf($sql, mysqli_real_escape_string($db, $login), $password);
$result = mysqli_query($db, $sql);
if (!$result || mysqli_num_rows($result) < 1) {
return "Не правильный логи или пароль";
}
<b>if (mysqli_result($result, 0, 'confirm') == 0) {
return "Пользователь с таким логином еще не продтвержден";
}</b>
$sess = md5(microtime());
$sql_update = "UPDATE " . PREF . "users SET sess='$sess' WHERE login='%s'";
$sql_update = sprintf($sql_update, mysqli_real_escape_string($db, $login));
if (!mysqli_query($db, $sql_update)) {
return "Ошибка авторизации пользователя";
}
$_SESSION['sess'] = $sess;
if ($post['member'] == 1) {
$time = time() + 10 * 24 * 3600;
setcookie('login', $login, $time);
setcookie('password', $password, $time);
}
return TRUE;
}
if ($post['member'] == 1) {
$time = time() + 10 * 24 * 3600;
setcookie('login', $login, $time);
setcookie('password', $password, $time);
}
Answer the question
In order to leave comments, you need to log in
if(mysqli_fetch_assoc($result)['confirm'] == 0) {
return ("Пользователь с таким логином еще не продтвержден");
}
//Looks like this condition doesn't work either. at least for me.
//Here is an analogue of mysql_result($result,0) :
//Create a function side by side at the top:
function mysqli_result($res,$row=0,$col=0){
$numrows = mysqli_num_rows($res);
if ($numrows && $row <= ($numrows-1) && $row >=0){
mysqli_data_seek($res,$row);
$resrow = (is_numeric($col)) ? mysqli_fetch_row($res) : mysqli_fetch_assoc($res);
if (isset($resrow[$col])){
return $resrow[$col];
}
}
return false;
}
//Then we write our result:
if(mysqli_result($result,0)==0) { //mysqli_result
return ("The user with this login has not yet been verified");
}
//in theory, it should work if you didn't confuse equality with != (not equal) in the condition
//Good luck!
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question