Warning: Cannot modify header information . . .
Posted: Wed May 21, 2008 6:05 pm
I get the following warning when I click "submit" at the end of my quiz:
Warning: Cannot modify header information - headers already sent by (output started at /home/alexbrew/public_html/results.php:3) in /home/alexbrew/public_html/results.php on line 52
Here's the code:
Here's the "sent.htm" that is reffered to in line 52:
Thanks!
Warning: Cannot modify header information - headers already sent by (output started at /home/alexbrew/public_html/results.php:3) in /home/alexbrew/public_html/results.php on line 52
Here's the code:
Code: Select all
<?php
$title = "Quiz Results";
echo "<title>$title</title>";
if (isset ($_POST['submit'])) {
$name = $_POST['name'];
$q1 = "1.)" . $_POST['q1'];
$q2 = "2.)" . $_POST['q2'];
$q3 = "3.)" . $_POST['q3'];
$q4 = "4.)" . $_POST['q4'];
$q5 = "5.)" . $_POST['q5'];
$qp = "6.)" . $_POST['qp'];
}
if ($name == "") {
die ("You forgot something, go back and check over your quiz.");
}
if ($q1 == "1.) ") {
die ("You forgot something, go back and check over your quiz.");
}
if ($q2 == "2.) ") {
die ("You forgot something, go back and check over your quiz.");
}
if ($q3 == "3.) ") {
die ("You forgot something, go back and check over your quiz.");
}
if ($q4 == "4.) ") {
die ("You forgot something, go back and check over your quiz.");
}
if ($q5 == "4.) ") {
die ("You forgot something, go back and check over your quiz.");
}
{
echo<<<EOT
<p>Results: $name<br>
$q1<br>
$q2<br>
$q3<br>
$q4<br>
$q5</p>
<p><a href="$qp">Go Back To Quiz?</a>
EOT;
}
$Name = $_POST['name'];
$Subject = "Quiz Results";
$Email = "abbrew@gmail.com";
$Message = "Here are the quiz results.";
$align = $_POST['align'];
$to = "$EmailTo";
$subject = "$Subject";
$body = "$Message\n\nQuiz By: $Name\n$q1\n$q2\n$q3\n$q4\n$q5";
mail($to,$subject,$body);
header("Location: sent.htm");
?>Code: Select all
<html>
<head>
<title>Message Sent</title>
</head>
<body>
<p>Your quiz has been sent to the webmaster. You should recieve a reply shortly. </p>
<p><a href="http://sweetwebsite.com/quiz00.php" target="_self">Go Back To Index?</a></p>
</body>
</html>