Answer the question
In order to leave comments, you need to log in
Doesn't alert the user?
Does not authorize the user on the site. I'm doing a very simple blog (just for myself). When I click login, I get a white screen. Here is the code. Doesn't see any errors.
<?php
$data = $_POST;
if (isset($data["do_login"])) {
$errors = array();
$users_log = mysqli_query($db_connect, "SELECT * FROM `users` WHERE `name` = '" . $data["login"] . "'");
if ( $data['login'] == $users_log["name"]) {
if (passwor_verify($data['password'], $users_log["pass"]) ) {
# code...
} else {
$errors[] = "Пароль не правильний";
}
} else {
$errors[] = "Користувач з таким именем не знайдений";
}
echo "<div style='color:red;'>" . array_shift($errors) . "</div> <hr>";
}
?>
Answer the question
In order to leave comments, you need to log in
Good afternoon.
You already ask the second question and write that there are no errors. But you get a white screen.
So maybe you should look into the server logs, the browser console, turn on error output to the browser? Raise, finally, the level of displayed errors.
It also does not hurt to arrange checks in the code.
There, you look, and the error will come out and you will figure out your problem yourself ...
ps
You can start with what is wrong here.
$data = $_POST;
if (isset($data["do_login"])) {
if (isset($_POST)) {
$data = $_POST;
// остальной Ваш код
}
$users_log = mysqli_query($mysqli, "SELECT * FROM `users` WHERE `username` = 'administrator'");
if ($users_log["username"] == 'administrator') {
if (passwor_verify($data['password'], $users_log["pass"]) ) {
# code...
} else {
$errors[] = "Пароль не правильний";
}
} else {
$errors[] = "Користувач з таким именем не знайдений";
}
echo "<div style='color:red;'>" . array_shift($errors) . "</div> <hr>";
Or maybe the data is not the same?
MB action is not the same. Or method is not equal to post. And the mb names are specified in the id, and not in the name attributes of the inputs, which also happens <form>...</form>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question