How to make a contact form
I decided to write this simple tutorial because a contact form should be very simple, easy and fast to create.Let’s start with creating the form itself.
-
-
<html>
-
<head>
-
<title>Contact</title>
-
</head>
-
<body>
-
<form action=”sendit.php” method=”POST”>
-
<p>Your Name: <input type=”text” name=”nume” size=”20″ /></p>
-
<p>Your Email: <input type=”text” name=”email” size=”20″/></p>
-
<p>Subject: <input type=”text” name=”subject” size=”20″/></p>
-
<p>Comments:<textarea name=”comments” cols=”50″ rows=”10″></textarea></p>
-
<input type=”submit” name=”submit” value=”Send” />
-
</form>
-
</body>
-
</html>
Save this as contact.html and let’s move on to the form processing.
-
<?php
-
@extract($_POST);
-
$name = stripslashes($name);
-
$email = stripslashes($email);
-
$subject = stripslashes($subject);
-
$comments = stripslashes($comments);
-
mail(‘YOUR_EMAIL@HERE.COM’,$subject,$comments,“From: $name <$email>”);
-
echo(“Thank you for your email!”);
-
?>
Save this as sendit.php and don’t forget to change YOUR_EMAIL@HERE.COM with your email.
Enjoy!:)
