<?php
//Designed by bexonsoft.com for domestic and personal use.
//Copy and paste the code and save as myform.php
//Change the file permission CHMOD to 755 (-rwxr-xr-x)
//Form must contain a field called 'email'
//Ideal form fields - 'name' 'subject' 'message' 'sendacopy'
//Add more fields without changing the code
if ($_POST['submit'] == TRUE) {
$myemail = "my@email.com"; // replace with your own email address
$ip = $_SERVER['REMOTE_ADDR'];
$message="Hello " . $name . ",\n\rThe message submitted:\n\r\n\r" . $message;
// validates the email address
if(!ereg("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)) {
echo "Email address invalid</p>";
}
else{
// includes any other variables you add to the form
while (list($key, $val) = each($HTTP_POST_VARS)) {
$variables .= "$key : $val\n";
}
// sends message to your inbox
mail($myemail, $subject, $variables . $message, "From: $email");
echo "<p>Thank you for your submission.</p>";
// sends autoresponse email
if($sendacopy=="checkbox"){
mail($email, $subject, $message, "From: $myemail");
echo "<p>A copy has been sent to " . $email . "</p>";
}
}
}
?>
//the form
<form method="post" action="">
<P>
<LABEL for="name">First name: </LABEL>
<INPUT type="text" name="name"><BR>
<LABEL for="email">Email: </LABEL>
<INPUT type="text" name="email"><BR>
<LABEL for="subject">Subject: </LABEL>
<select name="subject" name="subject">
<option>Technical</option>
<option>Sales</option>
<option>Suggestion</option>
</select><br>
<LABEL for="message">Message: </LABEL>
<INPUT type="textarea" cols="25" rows="3" name="message"><BR>
<LABEL for="sendacopy">Send a copy to my email: </LABEL>
<input name="sendacopy" type="checkbox" value="checkbox" checked><BR>
<INPUT type="submit" name="submit" value="Send"> <INPUT type="reset">
</P>
</form
|