Page 1 of 1

Headers and Redirects

Posted: Thu Apr 03, 2003 3:22 pm
by evilmonkey
Hello.

I have a question about headers. At what point in the program are they sent? Here is my code:

Code: Select all

$query="INSERT INTO users (username, password, name, email, icq, msn, aim, location, interests, music) VALUES ('$username', '$password', '$name', '$email', '$icq', '$msn', '$aim', '$location', '$interests', '$music')";
$result=mysql_query ($query, $db);
echo "Submission successful, you have registered.";
header ("Location = index.php");
And this is the error:

Code: Select all

Warning: Cannot add header information - headers already sent by (output started at c:\apache\htdocs\pc-dna\logging.php:16) in c:\apache\htdocs\pc-dna\logging.php on line 24
How do I got about fixing this? Also, Is there some kind of a delay function in PHP? I want the user to be able to see the message before they are re-directed, kind of like PHPBB.

Thanks.

Posted: Thu Apr 03, 2003 4:05 pm
by volka
please read Sticky: Before Post Read: Warning: Cannot add header information
It's not a sticky thread for nothing.

Posted: Thu Apr 03, 2003 6:39 pm
by evilmonkey
All right thanks.

I have found the javascript way to be easier (posted at the bottom of the aforementioned topic), how about the delay? I want my users to have 3-5 seconds to read the error (or success) message.

Thanks, sorry for my stupidity.

Posted: Thu Apr 03, 2003 6:49 pm
by volka
the page after submitting a new post here contains something like
<meta http-equiv="refresh" content="3;url=viewtopic.php?p=35597#35597">
it advises the client to load the document viewtopic.php... in three seconds. Most browsers support this

Posted: Thu Apr 03, 2003 8:45 pm
by evilmonkey
Thanks Volka. I got it.

Again, I must apologize for my stupidity earlier.

Cheers!

Posted: Fri Apr 04, 2003 2:50 am
by m3mn0n
Not stupidity, just lack of information. :D