|
Posted by Jerry Stuckle on 11/17/06 17:31
Jerim79 wrote:
> I have created a verification script to verify information and redirect
> the customer to the appropriate error page. For example:
>
> if ($FName=""){
> header('Location:/verify_fname.htm');
> }
> else{
> if ($LName=""){
> header('Location:/verify_lname.htm');
> }
> else{
> if ($Company=""){
> header('Location:/verify_company.htm');
> }
> else{
> if ($Title=""){
> header('Location:/verify_title.htm');
> }
> }
> }
> }
>
> The intent of the code is to check a variable. If an error is found in
> the variable, it redirects to the correct error page. Otherwise, it
> continues on through the else statement which then checks another
> variable and so and so on. The final else statement redirects to a
> process script that takes all the information writes it to a table. I
> am getting this error message:
> Cannot modify header information - headers already sent by
>
> I can't put the redirect before the HTML as I want the redirect to be
> conditional. Any help would be appreciated.
>
Jerim,
Why don't you want the redirect before the HTML? If you redirect the
user, you don't want the HTML to show, do you?
It can still be conditional. Put it at the top, and if everything is
OK, just have it fall through to the HTML.
BTW - this is a very user-unfriendly way of doing it. You should rather
check all the options, then if any are incorrect, redirect with all of
the invalid information. This way if there are three things wrong, the
user must gets an error message for the first one and corrects it. Then
he gets an error message for the second one, and so on.
If you check them all, you can display all three error messages at the
same time. Much more user friendly.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
[Back to original message]
|