ignore the last two irrelavent posts. You've already sent the headers because you've placed HTML content at the top of the page (before the <?PHP tags). It's giving you this error because you're then telling PHP to print more headers (directing them to the thanks page i think?) and PHP can't because you've already output to the browser.
So check this edited script out:
PHP Code:
<?php
//Configuration:
// number of friend's emails feilds to put on the page
$numberfriends = "5";
// subject of the email
$subject = "[This is not SPAM] A friend recommendation";
// Message sent in the email
$message = "Just found this website and it's really cool! It has all kind of stuff an Webmaster can need or want!";
// The url to redirect user to once they click submit
$endurl = "http://www.wise-designs.com/thanks.htm";
//Do not change bellow this line unless you know what you are doing!
if($submitform) {
$num=0;
while($num < $numberfriends) {
$num++;
$temail = "femail"."$num";
$tname = "fname"."$num";
if($$tname OR $$temail) {
if(!$$tname) {
$error .= "Missing Friends Name, Friend $num<BR>";
}
if(!$$temail) {
$error .= "Missing Friends Email, Friend $num<BR>";
}
}
if($$temail) {
if(!ereg("@",$$temail)) { $error .= "Invalid Email Address, Friend $num<BR>"; }
if(!ereg("\.",$$temail)) { $error .= "Invalid Email Address, Friend $num<BR>"; }
}
}
if(!$tname) {
$error .= "You must enter your name!<BR>";
}
if(!ereg("@",$email)) { $error .= "Invalid Email Address<BR>"; }
if(!ereg("\.",$email)) { $error .= "Invalid Email Address<BR>"; }
if($error) {
echo('
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Penaf Spread site!</title>
</head>
<body>
<p></p>
<center><table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="100%" bgcolor="#004080">
<table width="394" border="0" cellspacing="1" cellpadding="2">
<tr>
<td width="26%" bgcolor="#004080"><b><font color="#ffffff" size="-1" face="Verdana">Error</font></b></td>
</tr>
<tr>
<td width="26%" bgcolor="#ffffff"><font color="#000000" size="-1" face="Verdana">' . $error . '></font></td>
</tr>
</table></td>
</tr>
</table></center>
<p><center> </center></p>
</body></html>
');
exit();
}
$num=0;
while($num < $numberfriends) {
$num++;
$temail = "femail"."$num";
$tname = "fname"."$num";
$then = $$tname;
if($$temail AND $$tname) {
mail($$temail,"$subject","
Hey, $then !
$message
-$name
---------------------------------
http://www.wise-designs.com
","From: $name <$email>");
}
}
header("Location: $endurl");
exit();
} else {
$num=0;
while($num < $numberfriends) {
$num++;
$friendboxes .= " <TR>
<td width=\"49%\">
<font color=\"#000000\" size=\"-1\" face=\"Verdana\">$num</font></td>
<td width=\"26%\"><input name=\"fname$num\" type=\"text\" size=\"25\"></td>
<td width=\"25%\"><input name=\"femail$num\" type=\"text\" size=\"25\"></td>
</tr>";
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Penaf Spread site!</title>
</head>
<body>
<form action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="post"><p></p>
<center><table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="100%">
<table width="394" border="0" cellspacing="1" cellpadding="2">
<tr>
<td width="49%"></td>
<td width="26%"><font color="#000000" size="-1" face="Verdana">Your name</font></td>
<td width="25%"><font color="#000000" size="-1" face="Verdana">Your E-mail</font></td>
</tr>
<tr>
<td width="49%" valign="middle"></td>
<td width="26%"><center><input name="name" type="text" size="25" /></center></td>
<td width="25%"><center><input name="email" type="text" size="25" /></center></td>
</tr>
</table></td>
</tr>
</table></center>
<center><table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="100%">
<table width="394" border="0" cellspacing="1" cellpadding="2">
<tr>
<td width="49%"></td>
<td width="26%"><font color="#000000" size="-1" face="Verdana">Friends name</font></td>
<td width="25%"><font color="#000000" size="-1" face="Verdana">Friends email</font></td>
</tr><?php echo $friendboxes; ?>
<tr>
<td width="49%" valign="middle"></td>
<td width="26%"><p><input name="submitform" type="submit" value="Submit" /></p></td>
<td width="25%"><p><input type="reset" name="Reset" value="Reset" /></form></p></td>
</tr></table></td>
</tr>
</table></center></P>
</body></html>
<?php
exit();
}
?>
There you go, that should work, all i've done is moved the HTML from the top of your page to where they should be anyway. Remember that the header() can only be used before ANY output to browser.
Also, a common mistake can simply be a space before the first <?PHP tag (a painful mistake i made a while ago)
Check back to tell us the results
__________________
A lie gets halfway around the world before the truth has a chance to get its pants on. - Sir Winston Churchill
Please visit my sites: Please login or register to view this content. Registration is FREE | Please login or register to view this content. Registration is FREE
|