RE: [PHP] Cannot add header informatiom?

From: Date: Mon, 08 Oct 2001 06:13:58 +0000
Subject: RE: [PHP] Cannot add header informatiom?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-70320@lists.php.net to get a copy of this message
The word "Header" is self-explanatory :) You cannot send a "Header" (comes -before- HTML) after your script has sent HTML to the browser. You have two options-- Rearrange your code so the header is sent, if necessary, -before- any HTML output... Or, you can use output buffering functions. (see ob_start() and flush() in the manual) -----Original Message----- From: Jan Grafström [mailto:jan@grafstrom.net] Sent: Monday, October 08, 2001 2:05 AM To: php-general@lists.php.net Subject: [PHP] Cannot add header informatiom? Hi! I have this form to logon to page3.php, but always get warning message headers alredy sent. What am I doing wrong? Thanks for any help. Jan <? session_start(); include($DOCUMENT_ROOT."/database.inc"); function form() { echo "\n<form action=\"" . $PHP_SELF . "\" method=\"post\">"; echo "\n<P>Username"; echo "\n<br><INPUT NAME=\"user_name\" TYPE=\"text\" SIZE=\"20\"><br>"; echo "\n<P>Password"; echo "\n<br><INPUT NAME=\"password\" TYPE=\"password\" SIZE=\"20\"><br>"; echo "\n<input type=\"submit\" NAME=\"submit\" Value=\"Submit\">"; echo "\n</form>"; } //Start page echo "<html>\n<head>\n<title>Login example</title>\n</head>\n<body>"; form(); if ($user_name && $password) { $res = @mysql_query("SELECT user_name FROM user WHERE user_name='$user_name' AND password='$password'"); if(@mysql_num_rows($res) != 0) { $verified_user = $user_name; session_register("$verified_user"); Header("Location: http://www.myserver.com/page3.php"); } } echo "\n</body>\n</html>"; ?> Jan Grafström Lillemans Hus AB Sweden -- 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

« previous php.general (#70320) next »