This is a sample script to insert a generic contact form into your website.
You can easily modify the script, in order to use different fields or to modify the style.
(nota: is uses just plain mail() PHP command, so deliverability of the sent message may be quite poor)
<?php
$action=$_REQUEST['action'];
if ($action=="")
?>
<form action="" method="POST" enctype="multipart/form-data">
<input type="hidden" name="action" value="submit">
Name:<br>
<input name="name" type="text" value="" size="35"/><br>
Email address:<br>
<input name="email" type="text" value="" size="35"/><br>
Your message:<br>
<textarea name="message" rows="8" cols="40"></textarea><br>
<input type="submit" value="Send email"/>
</form>
<?php
}
else /* send the data */
{
$name=$_REQUEST['name'];
$email=$_REQUEST['email'];
$message=$_REQUEST['message'];
if (($name=="")||($email=="")||($message==""))
{
echo "Error! All fields are required, please fill <a href=\"\">the form</a> again.";
}
else{
$from="From: $name<$email>\r\nReturn-path: $email";
$subject="Message sent using your contact form";
mail("address@yourdomain.com", $subject, $message, $from);
echo "Thank you for your message!";
}
}
?>