Jun-28-2024, 01:53 PM
Quote:but what about outputting the error on the html form instead of just the console as end users wont see the console they will just have access to the html form
In PHP there is a kind of global array known as $_SESSION with elements like: $_SESSION["any name here"].
Once you start $_SESSION, you can store anything in it, like:
Quote:$_SESSION['isloggedin'] = 'False';
$_SESSION['email_error'] = "This email {$email} is not in the database."
$_SESSION['PWerror'] = '密码不一样 Passwords did not match';
$_SESSION['PWsuccess'] = '改变密码成功了!Password changed for User with email: ' . $email . '!';
The users clicks send and the PHP to evaluate the contents of the form takes over. If an error occurs, the user is bounced back to the form, where the error can be displayed as $_SESSION['any name here'] in a div and the $_SESSION error is unset, ready for the next attempt when the user clicks the send button again:
Quote:<div id="div-blue">
If something is wrong, you will see an error message here. <br>
<?php
if(isset($_SESSION['PWerror'])){
echo "An error occurred: " . $_SESSION['PWerror'] . '<br>';
unset($_SESSION['PWerror']);
}
if(isset($_SESSION['PWsuccess'])){
echo "Result: " . $_SESSION['PWsuccess'] . '<br>';
unset($_SESSION['PWsuccess']);
}
?>
</div><br>
Maybe Flask has something like $_SESSION?