A contact form?
easy - create the form with html and send the form output to a php script to handle the data. You can use the mail function to do this in php for example
http://www.w3schools.com/html/html_forms.asp
<form method="POST" action="contact.php">
Fields marked (*) are required
<p>Email From:* <br>
<input type="text" name="EmailFrom">
<p>Salutation:<br>
<input type="text" name="Salutation">
<p>FirstName:<br>
<input type="text" name="FirstName">
<p>LastName:<br>
<input type="text" name="LastName">
<p>PostCode:<br>
<input type="text" name="PostCode">
<p>HomeTel:<br>
<input type="text" name="HomeTel">
<p>Mobile:<br>
<input type="text" name="Mobile">
<p><input type="submit" name="submit" value="Submit">
</form>
// get posted data into local variables
$EmailFrom = Trim(stripslashes($_POST['EmailFrom']));
$EmailTo = "[email protected]";
$Subject = "Driving Lesson Enquiry";
$Salutation = Trim(stripslashes($_POST['Salutation']));
$FirstName = Trim(stripslashes($_POST['FirstName']));
$LastName = Trim(stripslashes($_POST['LastName']));
$PostCode = Trim(stripslashes($_POST['PostCode']));
$HomeTel = Trim(stripslashes($_POST['HomeTel']));
$Mobile = Trim(stripslashes($_POST['Mobile']));
// 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 .= "Salutation: ";
$Body .= $Salutation;
$Body .= "\n";
$Body .= "FirstName: ";
$Body .= $FirstName;
$Body .= "\n";
$Body .= "LastName: ";
$Body .= $LastName;
$Body .= "\n";
$Body .= "PostCode: ";
$Body .= $PostCode;
$Body .= "\n";
$Body .= "HomeTel: ";
$Body .= $HomeTel;
$Body .= "\n";
$Body .= "Mobile: ";
$Body .= $Mobile;
$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=ok.htm\">";
}
else{
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
}
?>
Doh! silly typo, should have spotted it earlier, add '<'?php' and '?>' around your code, it's just plaintext at the moment, no wonder it isn't executing, for example:
Code:<?php code goes here ?>
ZomgERROR said:The requested URL /error.htm was not found on this server.
The requested URL /error.htm was not found on this server.
Does that file exist (ie. have you created it)?
Just tested it, seems to work okay now, you should have a message from [email protected]
<form method="POST" action="contact.php">
Fields marked (*) are required
<p>FirstName:<br>
<input type="text" name="FirstName">
<p>LastName:<br>
<input type="text" name="LastName">
<p>PostCode:<br>
<input type="text" name="PostCode">
<p>HomeTel:<br>
<input type="text" name="HomeTel">
<p>Mobile:<br>
<input type="text" name="Mobile">
<p>Comments:<br>
<textarea cols="50" rows="4" name="Comment">Do you have your provisional? Previous experience? When is best to contact you?</textarea>
<p><input type="submit" name="submit" value="Submit">
</form>
<?php
// get posted data into local variables
$EmailTo = "[email protected]";
$Subject = "Driving Lesson Enquiry";
$FirstName = Trim(stripslashes($_POST['FirstName']));
$LastName = Trim(stripslashes($_POST['LastName']));
$PostCode = Trim(stripslashes($_POST['PostCode']));
$HomeTel = Trim(stripslashes($_POST['HomeTel']));
$Mobile = Trim(stripslashes($_POST['Mobile']));
$Comment = Trim(stripslashes($_POST['Comment']));
// validation
$validationOK=true;
if (!$validationOK) {
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
exit;
}
// prepare email body text
$Body = "";
$Body .= "FirstName: ";
$Body .= $FirstName;
$Body .= "\n";
$Body .= "LastName: ";
$Body .= $LastName;
$Body .= "\n";
$Body .= "PostCode: ";
$Body .= $PostCode;
$Body .= "\n";
$Body .= "HomeTel: ";
$Body .= $HomeTel;
$Body .= "\n";
$Body .= "Mobile: ";
$Body .= $Mobile;
$Body .= "\n";
$Body .= "Comment: ";
$Body .= $Comment;
$Body .= "\n";
// send email
$success = mail($EmailTo, $Subject, $Body);
// redirect to success page
if ($success){
print "<meta http-equiv=\"refresh\" content=\"0;URL=success.htm\">";
}
else{
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
}
?>
What error are you getting?
It comes back sucess for me, have you updated it since you posted?
// validation
$validationOK=true;