So I've tried publishing a page with PHP contact form on 2 different servers and I can't get either of them to work perfectly.
Server 1:
Returns a 500 internal error
page upon submission.
I contacted web support and they replied saying I have a:
malformed header from script 'index.php': Bad header:
My code for index.php as follows:
<?php
if(isset($_POST['submit']))
{
$name = $_POST['name'];
$email = $_POST['email'];
$query = $_POST['message'];
$email_from = $name.'<'.$email.'>';
$to="[email protected]";
$subject="test subject";
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= "From: ".$email_from."\r\n";
$message="
Name:
$name
<br>
Email:
$email
<br>
Message:
$query
";
if(mail($to,$subject,$message,$headers))
header("Location:../contact.php?msg=Successful Submission!<br />
Thank you for contacting us.");
else
header("Location:../contact.php?msg=Error To send Email !");
}
?>
Server 2:
Links me to my "Thank you page" correctly, but it's showing
"Error To send Email !" instead of
"Successful Submission!"
Any help or advice will be greatly appreciated!
I think the propblem is in this part:
Specificly in the
header();
<br />
would suggest a file called ">Thank you for contacting us."Check out: http://www.w3schools.com/tags/ref_urlencode.asp;
Also put
exit();
after each header to prevent futher execution of the script