|
Posted by Gordon Burditt on 11/17/06 23:35
>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.
You MUST put the redirect before outputting any HTML, and outputting HTML
after the redirect is somewhat pointless, as it won't be seen.
Your code doesn't contain any HTML, though. Code within <?php ... ?>
isn't output, and won't draw that error message. However, stuff outside
that, like blank lines, DOCTYPE, HTML, UTF-8 markers, etc. are and
will mess things up.
[Back to original message]
|