0

I recently updated my website to comply with MYSQLi standards and encountered several errors but after resolving the last error about "Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given" there is no error displaying in my error log but the pin validation page returns that the pin is invalid even when the pin is correct please help.

below is the function codes for the do validation

function doPinValidation() {
    $errorMessage = '';
    
    $pin = $_SESSION['glawsot_tmp']['pin'];
    $ipPin = $_POST['accpin'];
    
    if($pin ==$ipPin) {
        $_SESSION['glawsot_user'] = $_SESSION['glawsot_tmp'];
        unset($_SESSION['glawsot_tmp']);
        header('Location: index.php');
        exit;
    }
    else {
        $errorMessage = 'Invalid pin numbers, please try again.';
    }
    return $errorMessage;
}
Alberto Sinigaglia
  • 12,097
  • 2
  • 20
  • 48
GLAWSOT
  • 1
  • 1
  • And `$pin` contains....while `$ipPin` contains...(the values and types). Seriously, how could anyone possible answer this question without knowing these 2 details? In fact, if you'd have information about these details, you would automatically get your answer (*hint* `$errorMessage = 'Invalid pin numbers, please try again.' . '$pin='.$pin.' $ipPin='.$ipPin;` ) – vanowm Aug 14 '21 at 15:17
  • 1
    Welcome to StackOverflow. Please complete the [Tour](https://stackoverflow.com/tour) and read ["How to Ask"](https://stackoverflow.com/help/how-to-ask). If possible you should provide a [Minimal, Reproducible Example](https://stackoverflow.com/help/minimal-reproducible-example) – Marc Aug 14 '21 at 15:18
  • 1
    add `echo json_encode([$ipPin, $pin]); die();` just before the if statement – Alberto Sinigaglia Aug 14 '21 at 15:20
  • @vanowm i don't think that printing the pin in the error message is such a great idea... 90% it would end in production and kaboom everybody has access to the pin and so the validation is useless – Alberto Sinigaglia Aug 14 '21 at 15:21
  • @AlbertoSinigaglia true, either way it will be sent to the client unless they log it into a file instead. – vanowm Aug 14 '21 at 15:25
  • There is no mysqli standards. mysqli is an extension that was developed to help people upgrade from PHP 4 to PHP 5. New code usually doesn't use the mysqli extension anymore, so it's not even a PHP standard. – Dharman Aug 14 '21 at 16:44

0 Answers0