I do authorization on token'u and secret'ke. I can not find an error in logic, it still shows that the data is incorrect. When I do only by token, everything works, and when by 2 values - an error.
<?php function _auth() { session_start(); include 'connect.php'; $sql = "SELECT * FROM `users`"; $result = mysqli_query($mysqli,$sql); while($user = mysqli_fetch_assoc($result)) { $token=$user['token']; $secret=$user['secret']; if (isset($_POST['token'], $_POST['pass_btn'], $_POST['secret'])) { if ($token == $_POST['token'] and $secret == $_POST['secret']) { $_SESSION['unique_sdfcdrgbtrhbgfnb'] = true; } else { $_SESSION['sdfcdrgbtrhbgfnb'] = false; echo '<div>Failed token or secret</div>'; } } if ($_SESSION['unique_sdfcdrgbtrhbgfnb'] !== true) { echo '<form method="POST">'. '<div>Enter token:<br /><input type="text" name="token" size="50" /></div>'. '<div>Enter secret:<br /><input type="text" name="secret" size="50" /></div>'. '<div><input type="submit" value="Enter" name="pass_btn" /></div>'. '</form>'; die(); } } } _auth(); ?>
$_SESSION['unique_sdfcdrgbtrhbgfnb'] = true;and hereinafter$_SESSION['sdfcdrgbtrhbgfnb'] = false;is it so conceived? - ReinRaus$user['secret']is not the same as in$_POST['secret'], that's why it does not work. The easiest way to debug - inside each condition / branch else and outside the condition, you draw a conclusion of a unique value and see where exactly the logic broke, i.e. See which branch the algorithm went to. Then see why it went on this thread, and not on the right one, etc. - BOPOH