mercredi 27 février 2019

PHP - If statement comparing string with contents of txt file

I did some research and couldn't find a clear answer to my problem. This is what I have:

<?php
    session_start();
    $gen_num = file_get_contents($_SESSION['filename']);
    $inp_num = $_POST['form-input'];
    if($gen_num === $inp_num){
        echo "Yes! The numbers match!";
    } else {
        echo "No, the numbers do not match&hellip;";
    }
?>

Where the 'filename' has a string of numbers and 'form-input' is carried from a previously submitted HTML form.

Why does the IF test fail when the strings are identical?

Aucun commentaire:

Enregistrer un commentaire