I've made a contact form on a website, and it send the user to a page that should redirect them back to the contact form after three seconds.
This is that code:
PHP Code:
<?php
function spamcheck($field)
{
//filter_var() sanitizes the e-mail
//address using FILTER_SANITIZE_EMAIL
$field=filter_var($field, FILTER_SANITIZE_EMAIL);
//filter_var() validates the e-mail
//address using FILTER_VALIDATE_EMAIL
if(filter_var($field, FILTER_VALIDATE_EMAIL))
{
return TRUE;
}
else
{
return FALSE;
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
body {
padding: 0px;
margin: 0px;
font: 11px Arial, Helvetica, sans-serif;
color: rgb(32,32,32);
text-align:center;
}
</style>
</head>
<body>
<?php
if (isset($_REQUEST['email']))
{
$mailcheck = spamcheck($_REQUEST['email']);
if ($mailcheck == FALSE)
{
?>
Invalid input.
<?php
}
else
{
$name = $_REQUEST['name'];
$email = $_REQUEST['email'];
$phone = $_REQUEST['phone'];
$comments = $_REQUEST['comments'];
$to = "martin@logobee.com";
$subject = "Mail from -- contact form from $name";
if (isset($_REQUEST['add_to_mailing_list']))
{
$message = "Name: $name \n E-mail: $email \n Phone Number: $phone \n This user wants to be added to the mailing list \n $comments";
}
else
{
$message = "Name: $name \n E-mail: $email \n Phone Number: $phone \n $comments";
}
mail($to,$subject,$message, "From: $email");
?>
E-mail sent successfully to <?php echo $to; ?>, redirecting in 3 seconds...
<?php
}
//sleep for 3 seconds
sleep(3);
//redirect
header("Location: http://www.---.ca/contact.htm");
}
?>
But when I've tested it on the server, I get the following error message:
Warning: Cannot modify header information - headers already sent by (output started at /home/content/d/a/v/---r/html/contact.php:24) in
/home/content/d/a/v/---/html/contact.php on line
73
The site is hosted on godaddy.com , does anyone know why this is happening?
EDIT: I've removed any information that would identify the website, because it's not mine and I can't give away my client's information