Reply to Re: header() with if/then statements

Your name:

Reply:


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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация