S
S
sandul232021-10-05 19:23:34
PHP
sandul23, 2021-10-05 19:23:34

How to fix authorization on the site?

I am making an online game based on the prehistoric "core" of year 16. When I try to authorize (the script requests access to the database and everything is processed there by gypsy magic, cookies are recorded and there should be a redirect to the game page) the redirect does not want to happen: there are no errors, the data is correct , but either something is wrong with the cookies, or something else. Please help

$login = _string($_POST['login']);
$password = _string($_POST['password']);

if($login && $password) {
$q = mysql_query('SELECT * FROM `users` WHERE `login` = "'.$login.'" AND `password` = "'.$password.'" LIMIT 1');
 
$user = mysql_fetch_array($q);

    if(!$user) {
echo '<div class="block center">Неверные данные!</div>';
}
      if($user) {
    
    setCookie('id', $user['id'], time() + 86400 * 365, '/');
setCookie('password', $password, time() + 86400 * 365, '/');
    
         header('location: /game.php');
         
 
      
      }
      }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
ThunderCat, 2021-10-05
@ThunderCat

there is no error, the data is correct,
Holy naivete...
1) Turn on error output
2) 99% that everything works on a fresh version of PHP, where they have long forgotten what mysql_query is
3)
or something else
Yes, definitely something else, see point 1

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question