Re: redirecting in the middle of a code



sheldonlg wrote:
Paul Lautman wrote:
Raistlin Majere wrote:
if ($email != VALID_email)
{
header("Location: create3.php?error=invalid_email");
} else if (!empty($db_email)) {
header("Location: create3.php?error=already_email");
} else {
if($password != VALID_PASSWORD)
{
header("Location: create3.php?error=invalid_password");
} else if (!empty($db_password)) {
header("Location: create3.php?error=already_password");
} else {
mysql_query('INSERT INTO `accounts` VALUES (``, $email,
$password)');
header("Location: index.php");
}
}
mysql_close();


Warning: Cannot modify header information - headers already sent by
(output started at C:\AppServ\www\opinionsofamateurs\accounts
\create2.php:12) in C:\AppServ\www\opinionsofamateurs\accounts
\create2.php on line 32


How to solve?

It is a 5 step process:

1) Go to groups.google.com
2) In the search box put Warning: Cannot modify header information
3) Click on the first article at the top of the page (it is an
article in this group)
4) Read
5) Think to yourself, why didn't I do that at the start.



Very good, Paul, and normally I would not have written anything after
laughing (the way I did). However, on examining the code, I don't see
any print or echo statement to have caused this.
Correct, the post that I referred him to talks about the whitespace which
usually causes this problem.

Mind you, not that there are no php tags here either. He has obviously
posted only a small portion of the code and the offending echo or whitespace
occurs somewhere else.

So, to Raistlin,
don't look at THIS piece of code. It is not causing your problem. Look,
instead, at the piece where you have already done and echo or a
print.
Hint: Do what Paul said.



.



Relevant Pages