I am trying to make a contact form for my web site so that people can email me questions, this may seem like a simple task but I am a beginer and have hit a brick wall and really need some help.
This is my contactus.html were the form is to be located, the form looks ok, bar the fact that I cant get the submikt button I made to work so I just have the bog standard one next to it for the time being. ( also I do not now how to get the clear button to work) the web address of the form is http://estuffhosting.com/contactus.html. Here is the code:
<tr>
<td> </td>
<form method="POST" action="contactus.php">
<td align="left" valign="top" class="sel4">Username:</td>
<td height="25" align="left" valign="top" class="text"><input type="text" name="Username" style="width: 200px; height: 18px"></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td align="left" valign="top" class="sel4">Email:</td>
<td height="25" align="left" valign="top" class="text"><input type="text" name="Email" style="width: 200px; height: 18px"></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td align="left" valign="top" class="text">Message:</td>
<td height="25" align="left" valign="top" class="text"> <textarea name="Message" style="width: 250px; height: 120px"></textarea></td>
<td> </td>
</tr>
<tr>
<td width="12"> </td>
<td align="left" valign="top" class="text"> </td>
<td height="30" align="right" valign="bottom"> <a href="#"><img src="images/clear.jpg" width="62" height="18" border="0"></a> <img src="images/send.jpg" width="61" height="18" border="0"> <input type="submit" name="Submit" value="Submit"></form>
<br> </td>
<td width="12"> </td>
</tr>
</table> </td>
here is the php file - /contactus.php :
<?php
// get posted data into local variables
$EmailFrom = Trim(stripslashes($POST['EmailFrom']));
$EmailTo = "email@example.com";
$Subject = "email@example.com";
$Username = Trim(stripslashes($POST['Username']));
$Email = Trim(stripslashes($POST['Email']));
$Message = Trim(stripslashes($POST['Message']));
// validation
$validationOK=true;
if (Trim($EmailFrom)=="") $validationOK=false;
if (!$validationOK) {
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.html\">";
exit;
}
// prepare email body text
$Body = "";
$Body .= "Username";
$Body .= $Username;
$Body .= "\n";
$Body .= "Email";
$Body .= $Email;
$Body .= "\n";
$Body .= "Message";
$Body .= $Message;
$Body .= "\n";
// send email
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");
// redirect to success page
if ($success){
print "<meta http-equiv=\"refresh\" content=\"0;URL=contactus.html\">";
}
else{
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
}
?>
All that happens is it doesn't send an email and it takes you to the error page. All I want to do is fix it, but I cant figre it out, can anyone help?
thanks