I
I
Ivan Ivanov2018-04-22 13:32:38
PHP
Ivan Ivanov, 2018-04-22 13:32:38

Why redirect?

Hello. I have a login page, but if you enter the wrong login or password, or even if the data does not pass regular expressions, then it redirects to blog.glezer.ru/login? . Well, respectively, writes that the page is not found. Here is the link blog.glezer.ru/login. Here is the login handling code:

}else if($_POST['login_f']){
    login_valid();
    password_valid();
    if ( !mysqli_num_rows(mysqli_query($CONNECT, "SELECT `id` FROM `users` WHERE `login` = '$_POST[username]' AND `password` = '$_POST[password]'")) ){
        message('Аккаунт не найден');
    }
        $row = mysqli_fetch_assoc( mysqli_query($CONNECT, "SELECT * FROM `users` WHERE `login` = '$_POST[username]'") );
        foreach ($row as $key => $value)
      $_SESSION[$key] = $value;
        go('profile');

}

Here are the password_valid() and login_valid() functions:
function password_valid() {
  if ( !preg_match('/^[A-z0-9]{7,30}$/', $_POST['password']) )
    message('Пароль указан неверно и может содержать 7 - 30 символов');
    
  $_POST['password'] = md5($_POST['password']);
}
function login_valid() {
  if ( !preg_match("/^[A-z0-9]{7,30}$/", $_POST['username']) ){
    message('Логин указан неверно и может содержать 7 - 30 символов');
    }
}

If everything is entered correctly, then the entrance occurs and everything is fine. I can't find any error. Thanks in advance

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey, 2018-04-22
@maksim_fix

Well, everything is correct. Form submit occurs. need to cancel it

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question