Hi,
I’ve been having serious difficulty trying to get my contact form to work. I am very inexperienced with PHP, so I’d imagine this is a simple question.
I would greatly appreciate any help. Thanks in advance.
URL: http://www.austinlindsay.com/contact.html
Here’s the code:
contact.html:
<div id=“contact_form”><form method=“POST” action=“contact.php”>
Fields marked (*) are required
<p>Email From:* <br>
<input type=“text” name=“EmailFrom”>
<p>Subject: <br>
<input type=“text” name=“Subject”>
<p>Name:<br>
<input type=“text” name=“Name”>
<p>YourMessage:<br>
<textarea name=“YourMessage”></textarea>
<p><input type=“submit” name=“submit” value=“Submit”>
</form>
<p>
<!-- Contact Form credit link -->
Created by <a target="_blank"
href=“http://www.tele-pro.co.uk/scripts/contact_form/”>Contact
Form Generator</a></div>
contact.php:
<?php
// Website Contact Form Generator
// http://www.tele-pro.co.uk/scripts/contact_form/
// This script is free to use as long as you
// retain the credit link
// get posted data into local variables
$EmailFrom = Trim(stripslashes($_POST[‘EmailFrom’]));
$EmailTo = "jlindsay101@aol.com";
$Subject = Trim(stripslashes($_POST[‘Subject’]));
$Name = Trim(stripslashes($_POST[‘Name’]));
$YourMessage = Trim(stripslashes($_POST[‘YourMessage’]));
// validation
$validationOK=true;
if (Trim($EmailFrom)=="") $validationOK=false;
if (!$validationOK) {
print “<meta http-equiv=“refresh” content=“0;URL=error.htm”>”;
exit;
}
// prepare email body text
$Body = “”;
$Body .= "Name: ";
$Body .= $Name;
$Body .= “
”;
$Body .= "YourMessage: ";
$Body .= $YourMessage;
$Body .= “
”;
// send email
$success = mail($EmailTo, $Subject, $Body, “From: <$EmailFrom>”);
// redirect to success page
if ($success){
print “<meta http-equiv=“refresh” content=“0;URL=ok.htm”>”;
}
else{
print “<meta http-equiv=“refresh” content=“0;URL=error.htm”>”;
}
?>