Here's a contact form I made. If you have any problems ask me.
Create a HTML or PHP file called contact. with this...
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>THE TITLE OF YOUR CONTACT FORM</title>
</head>
<body>
<form action="mail.php" method="post" name="mail">
<font color="#000000">Name:</font><br>
<input name="name" type="text" size="50" maxlength="50" /><br>
<font color="#000000">E-mail:</font><br>
<input name="email" type="text" size="50" maxlength="50" /><br>
<font color="#000000">Subject:</font><br>
<select name="subject">
<option value="Please select a topic....." selected="selected">Please select a topic.....</option>
<option value="Leave a comment">Leave a comment</option>
<option value="Report a site problem">Report a site problem</option>
<option value="Ask a question">Ask a question</option>
<option value="Other (please explain below)">Other (please explain below)</option></select><br>
<font color="#000000">Comment:</font><br>
<textarea name="comment" cols="50" rows="10"></textarea><br>
<input type="checkbox" name="copy"><font size="2">Send me a copy of the email.</font><br><p></p>
<input name="submit" type="submit" value="Send" /><input name="reset" type="reset" />
</form>
</body>
</html>
create a PHP file called mail.php
PHP Code:
<?php
//Variables.
$user_email = $_REQUEST['email'];
$user_name = $_REQUEST['name'];
$user_subject = $_REQUEST['subject'];
$user_comment = $_REQUEST['comment'];
$user_send = $_REQUEST['copy'];
$user_check = stripos("$user_email","@");
//Body of the email to be sent.
$body_mail = "Hello YOURANME, someone wants to contact you.. Details..
Name: $user_name $user_lastname
Email: $user_email
subject: $user_subject
Comment: $user_comment.";
//Body of the Email for the user requesting a copy.
$body_email = "
Here is a copy of the email.
Your Name: $user_name $user_lastname.
Your Email: $user_email.
Your subject: $user_subject.
Your Comment: $user_comment.
Thank you for contacting us, we'll reply ASAP.
Yourwebsite team.";
//Check if the user submited the data require.
//If the @ is measing from the email address stop the user for continuing.
if ($user_check) {
echo "";
}
else {
echo "You can't continue with out a email address, Please enter a email address.";
exit ($user_check);
}
if (empty($user_name)) {
echo "<center><h2><font color='ff0000'>ERROR</font></h2></center>You didn't enter a your first name.<br>";
exit();
}
elseif (!$user_comment) {
echo "<center><h2><font color='ff0000'>ERROR</h2></center></font>Please enter a comment.";
die();
}
//Everything okay? send the e-mail.
else {
mail('YOUREMAIL','Email from YOURWEBITE',"$body_mail","from:YOURWEBSITE");
echo "your email was sent! Thank you.";
}
//If the checkbox if check send a copy to the user.
if (isset($user_send)) {
@mail("$user_email","The copy of your information from YOURWEBSITE","$body_email","YOURWEBSITE");
echo "And a copy of the Email was send to you!";
}
else {
die($user_send);
}
?>
You have to change where it says YOUREMAIL, YOURNAME etc.