Hello, I have a basic knowledge of css and html, but my php skills are less than adequate. So I'm hoping you guys can help me. I've modified this one form a couple times, but this time I can't seem to make it work.
I have a contact.html page that should "post" to email-form.php... but I get an "unexpected $end" error when I click submit.
Here's the form html code from the contact.html page...
<form name="contact" method="post" action="email-form.php">
<input type="hidden" name="form" value="contact">
<table width="625" border="0" cellspacing="5" cellpadding="0">
<tr>
<td width="172" align="right" valign="middle"><label>Name: </label></td>
<td width="438" valign="middle">
<input name="name" type="text" id="name" size="55" />
</td>
</tr>
<tr>
<td align="right" valign="middle"><label>Email: </label></td>
<td valign="middle"><input name="email" type="text" id="email" size="55" /></td>
</tr>
<tr>
<td align="right" valign="middle"><label>Website (optional): </label></td>
<td valign="middle"><input name="website" type="text" id="website" size="55" /></td>
</tr>
<tr>
<td align="right" valign="middle"> </td>
<td valign="middle"> </td>
</tr>
<tr>
<td align="right" valign="middle"><label>Subject: </label></td>
<td valign="middle"><input name="subject" type="text" id="subject" size="55" /></td>
</tr>
<tr>
<td align="right" valign="top"><label>Message:</label></td>
<td valign="top"><textarea name="message" id="message" cols="55" rows="5"></textarea></td>
</tr>
<tr>
<td align="right" valign="top"> </td>
<td valign="top"><label>
<input name="submit" type="submit" class="button" value="submit" />
</label></td>
</tr>
</table>
</form>
And here's the code on the email-form.php page:
<?php
$error = "";
$ResponseBody = "";
If ($_POST['form'] == "contact") {
If (strlen($_POST['name']) < 2) { $error = $error . "Please provide your name.<br>"; }
If (strlen($_POST['email']) < 2) { $error = $error . "Please provide an email address.<br>"; }
If (strlen($error) < 2) {
$subject = "Contact via MerissaAldrich.com";
$ResponseBody = $ResponseBody . "Name: " . $_POST['name'] . "<br>";
$ResponseBody = $ResponseBody . "Email: " . $_POST['email'] . "<br><br><br>";
$ResponseBody = $ResponseBody . "Website: " . $_POST['website'] . "<br>";
$ResponseBody = $ResponseBody . "Subject: " . $_POST['subject'] . "<br><br>";
$ResponseBody = $ResponseBody . "Message: " . $_POST['message'] . "<br><br>";
} Else {
}
If (strlen($error) < 2) {
//--- SEND EMAIL ----------------------------------
$to = "info@myurl.com";
$headers = "From: myurl.com <info@myurl.com>\n";
$headers .= "X-Sender: <info@myurl.com>\n";
$headers .= "X-Priority: 3\n"; //1 UrgentMessage, 3 Normal
$headers .= "Return-Path: <info@myurl.com>\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
mail ($to, $subject, $ResponseBody, $headers);
?>
<h1><em>Thanks!</em></h1>
<p><span class="black">I'll get back to you within the week. :)<br>
</p>
<p>< Back to <a href="index.html">myurl.com</a>. </p>
<? } Else { ?>
<h1><em>Oops</em></h1>
<p><span class="black">Your form submission was incomplete</p>
<p><font color="red"><?=$error;?></font></p>
<p><a href="javascript: history.go(-1)">Go Back</a></p>
<? } ?>
?>
Help? 😕