RE: [PHP-DB] another newbie question...

From: Date: Mon, 16 Sep 2002 15:25:34 +0000
Subject: RE: [PHP-DB] another newbie question...
Groups: php.db 
Request: Send a blank email to php-db+get-21778@lists.php.net to get a copy of this message
The error "Cannot add header information" indicates you are trying to re-direct a user AFTER text has already been sent to their browser. If you are going to re-direct someone you must do it prior to sending any previous header/text information to their browser. <?php echo "Text"; header("Location: http://www.amazon.com"); ?> The above will fail as information has already been sent to them. The correct way is <?php header("Location: http://www.amazon.com"); echo "Text"; ?> Thanks, JT -----Original Message----- From: epeloke@echoman.com [mailto:epeloke@echoman.com] Sent: Monday, September 16, 2002 11:40 AM To: php-db@lists.php.net Subject: RE: [PHP-DB] another newbie question... So, I would actually use this code somewhere in the page that has the form to enter the username to send to a blank page that then redirects based on the username? I tried to put it in the page that is called by the form action on the form page but I get a warning that: Warning: Cannot add header information - headers already sent by (output started at c:\program files\apache group\apache\htdocs\redirect.php:1) in c:\program files\apache group\apache\htdocs\redirect.php on line 5 So I assume I need to add it to the signin page to send..correct? Thanks for being patient with me, Eddie -----Original Message----- From: Jackson Miller [mailto:lists@jaxn.org] Sent: Monday, September 16, 2002 11:04 AM To: 'Edward Peloke'; php-db@lists.php.net Subject: RE: [PHP-DB] another newbie question... Like this: <?php if ("eddie" == $username) { header("Location: http://www.amazon.com"); } else if ("Jackson" == $username) { header("Location: http://www.php.net"); } ?> Why: Conditions for if statements should be in parentheses Checking equality is == Using one = sets the variable Placing the username before the $username variable in the statement ensures that if you accidently enter = instead of == it will fail instead of setting the variable and passing. The header() function is a great way to send http headers. Hope this helps, -Jackson -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.db (#21778) next »