hello everyone , I am beginner in PHP, I have a problem ,

I have a login page (login.php), where user can enter some necessary information ,after submiting ...it goes to another php page(submit.php) and do something there , ... however on that submit.php it perform some business logic validation .. if it finds some error there ... it should redirect to the login.php page with some error message ( may be more than one error messages).... and the error messages should be display in the top of the login.php page .


i don't want to set the error message in the query string in the time of redirection... since there may be a array of error message ..

please help me .... in this regards with some sample code

hello everyone , I am beginner in PHP, I have a problem ,

I have a login page (login.php), where user can enter some necessary information ,after submiting ...it goes to another php page(submit.php) and do something there , ... however on that submit.php it perform some business logic validation .. if it finds some error there ... it should redirect to the login.php page with some error message ( may be more than one error messages).... and the error messages should be display in the top of the login.php page .


i don't want to set the error message in the query string in the time of redirection... since there may be a array of error message ..

please help me .... in this regards with some sample code

hi ..
there is another way to do this ..i.e By using sessions..try to do this by using sessions..

put the validation on the same page. don't let them go to the next page until the first page is completed successfully.

Also if you plan to have a lot of traffic you can use url's and arrays. Simply assign each error message a number and place each number in the url $_GET tag then use something like the following to retrieve the errors.

<?
//$_GET['errs']=1-3-5-6
$errors=explode('-',$_GET['errs']);
$error[0]='This is the first error message<br>';
$error[1]='This is the second possible error message<br>';
$error[2]='Example: Name field too short<br>';
$error[3]='This is another possible error message<br>';
$error[4]='There are some empty fields<br>';
$error[5]='Example error<br>';
$error[6]='Many more errors can be added<br>';
$finalerror=''; //avoid e_notice error
foreach($errors AS $err) {
$finalerror.=$error[$err];
}
//Now to display the errors
echo $finalerror;
?>
This article has been dead for over six months. Start a new discussion instead.