I've looked through the F.A.Q. for this but I'm not seeing why I'm getting the headers issue. I know where and what's making it throw it, but I need this to send the cookie and it will not.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Annuity, Annuity Advice, variable annuity, fixed annuity</title>
<meta content="Variable and fixed annuity resource. Get annuity advice on different types of variable and fixed annuities from top-rated companies." name="description">
<meta content="fixed annuities, variable annuities, Annuity Advice, annuity, annuities, fixed annuity, variable annuity, retirement annuity, Choosing an Annuities Agent, fixed annuity rate, Annuity Resources, Good or Bad Annuities, " name="keywords">
<meta content="GLOBAL" name="DISTRIBUTION">
<meta content="www.Annuityiq.com" name="AUTHOR">
<meta content="index,follow,archive" name="Googlebot">
<meta content="index,follow" name="Robots">
<meta content="3" name="revisit-after">
<script language="javascript">
function disableField()
{
document.formemail.submit.disabled=true;
}
function enableField()
{
document.formemail.submit.disabled=false;
}
</script>
</head>
<BODY onLoad="javascript:disableField()">
<!--#include virtual="header.html"-->
<div align='left' style="padding-left: 15px; padding-top: 5px;" class="style5">
<?php
if(!isset($submit)){
if($_COOKIE["annuityform"]) {
echo('<meta http-equiv="Refresh" content="0;url=http://www.yahoo.com">');
} else {
echo "
<form action='$_SERVER[PHP_SELF]' method='post' name='formemail'>
Name:<input type='text' name='name'><br>
Email:<input type='text' name='email'> Please enter a valid work email address; ex. johnsmith@yourfirm.com<br>
Phone:<input type='text' name='txtPhone'> Phone number must be in ###-###-#### form.<br>
Agree to terms: <input type='checkbox' name='checkbox' value='off' onClick='javascript:enableField()'> You agree that you are a financial advisor and not a consumer and you hold a vaild series 7 or 6 license.<br>
<input type='submit' name='submit' value='Submit' OnClick='javascript:ValidateForm()'>
</form>
";
}
}else{
//scottdemonte@annuityiq.com
$to="burstroo@gmail.com";
$from = $_POST['email'];
$message = $_POST['name'];
$message .= ' - '.$_POST['email'];
$message .= ' - '.$_POST['txtPhone'];
$subject = "Brokers Forum";
$submit = $_POST['submit'];
$headers .= "From: $from";
/***
** Check for empty fields
***/
if ((trim($from) == '')
|| (trim($_POST['name']) == '')
|| (trim($_POST['email']) == '')
|| (trim($_POST['txtPhone']) == '')) {
echo "You must fill out ALL parts of the form. <FORM><INPUT type='button' value='Click here to go back' onClick='history.back()'></FORM>";
/***
** END Check for empty fields
***/
} else {
/***
** Function to validate emails
***/
function check_email_address($email) {
// First, we check that there's one @ symbol, and that the lengths are right
if (!ereg("^[^@]{1,64}@[^@]{1,255}$", $email)) {
// Email invalid because wrong number of characters in one section, or wrong number of @ symbols.
return false;
}
// Split it into sections to make life easier
$email_array = explode("@", $email);
$local_array = explode(".", $email_array[0]);
for ($i = 0; $i < sizeof($local_array); $i++) {
if (!ereg("^(([A-Za-z0-9!#$%&'*+/=?^_`{|}~-][A-Za-z0-9!#$%&'*+/=?^_`{|}~\.-]{0,63})|(\"[^(\\|\")]{0,62}\"))$", $local_array[$i])) {
return false;
}
}
if (!ereg("^\[?[0-9\.]+\]?$", $email_array[1])) { // Check if domain is IP. If not, it should be valid domain name
$domain_array = explode(".", $email_array[1]);
if (sizeof($domain_array) < 2) {
return false; // Not enough parts to domain
}
for ($i = 0; $i < sizeof($domain_array); $i++) {
if (!ereg("^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])|([A-Za-z0-9]+))$", $domain_array[$i])) {
return false;
}
}
}
return true;
}
/***
** Validate that email
***/
if (check_email_address($_POST['email'])) {
// Is valid and...
/***
** Check for a bad phone number
***/
if(ereg("^[0-9]{3}-[0-9]{3}-[0-9]{4}$", $_POST['txtPhone'])) {
/***
** Send the email
***/
if(mail($to,$subject,$message,$headers)){
setcookie ("annuityform", "To make sure you never have to fill out the email form", time( ) + 311040000);
/***
** Email Could not send
***/
}else{
// blah
}
/***
** If a bad number is present
***/
} else {
echo "You must fill out a proper phone number. <FORM><INPUT type='button' value='Click here to go back' onClick='history.back()'></FORM>";
}
} else {
// Is not valid and...
echo "You must fill out a proper email address. <FORM><INPUT type='button' value='Click here to go back' onClick='history.back()'></FORM>";
}
}
}
?>
</div>
</body>
</html>
There error says..
Warning: Cannot modify header information - headers already sent by (output started at /home/demsco1/public_html/member/advisorcert.php:6) in /home/demsco1/public_html/member/advisorcert.php on line 136