PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Hi. After somebody types in the user name and password for my login form the password is validated in a different script. If it fails validation then I want the user to see the login page Plus a piece of text saying their password didn't pass validation.
this would work, the only problem is that it will show the text at the beginning of the login page. I want it to show the error message in a specifict table within the login page
there is a lot of code though ... and that code is in different files.
Basically what I am trying to do is: when a use inputs a wrong password (validation.php will verify it) he will be directed back to the login page, and on the login page the error is going to be shown. Though the login page is pretty complex with css and stuff... so
i could do it the way I wrote about at the beginning of the post..
it will show the error on the top of the page.
I need the error to be shown somewhere in the middle of the login page ... this is my problem
thanks!
I thought about splitting the login page into two and write the error in the middle
<?php
$error_msg = '';
$show_form = true;
// Do some checking and validating
// If the form data is good, set $show_form to false
if (FORM_DATA_IS_GOOD)
{
$show_form = false;
}
// If it is not good, add an error message to $error_msg
else
{
$error_msg = 'The form was not good';
}
// Now if the show form var is true, show the form
if ($show_form) {
?>
<form>
<?php echo $error_msg; /* will be blank if there is no error, like first load */ ?>
<input type="text" name="something" />
</form>
<?php
}
?>
This is of course a very rough idea of what I would do in your case. But it might point you in the right direction.