Re: Header() don't work
| From: | Jason G. | Date: | Mon, 15 Oct 2001 04:30:11 +0000 |
| Subject: | Re: Header() don't work | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-71058@lists.php.net to get a copy of this message | ||
I just had the same problem. MAKE sure all your include files have NO WHITESPACE before or after the <? ?>
-Jason Garber
IonZoft.com
At 12:04 PM 10/15/2001 +0800, Web user wrote:
I don't think there are any html output sent out before the header() in the login.php, so the header() should redirect to other page.(of course, the login name and password are right.) But the IE shows error as below: Warning: Cannot add header information - headers already sent by (output started at c:\program files\apache group\apache\htdocs\web\lib.inc:18) in c:\program files\apache group\apache\htdocs\web\login.php on line 18 The other question is can I put the session_start() after the line where the login is ok; But if I do so, error showed: Warning: Cannot send session cache limiter - headers already sent (output started at c:\program files\apache group\apache\htdocs\web\lib.inc:18) in c:\program files\apache group\apache\htdocs\web\6.php on line 16 In brief, what I need is redirection by header() and the generating of a session when after the login is ok. Thanks Mike -------------------------------------------------------------------------- (The scripts below are named as login.php which process the login form in the login.htm. ) login.php <? session_start(); if($submit!=""){ if($login_name!=""&&$login_password!=""){ $link=mysql_connect("localhost","",""); $link=mysql_select_db("db"); $query="select password, user_id from users where user_name='$login_name'"; $res=mysql_query($query); $num=mysql_num_rows($res); if($num==0) echo "The login name or password is not right!<br>"; if($num==1){ $arr=mysql_fetch_array($res);if(!strcmp($arr['password'], $login_password)){ /* ??? can I put the session_start(); here? For from here the login isok, and the session is actually needed.*/$user_id=$arr['user_id']; session_register("user_id"); header("location: page2.php"); /* Turn to page2.php automatically,but error showed here while running */exit(); }else echo "The login name or password is not right!<br>";} } } ?> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net