PHP Tutorial : Send email with a contact form

In this php tutorial you will learn how to setup a simple contact form which will be sent then by email. That needs to be done in two sides : html form and php contact form processing.

Html side is right here :

<form action="" method="POST">
Full name : <input type="text" name="fullname"><br/>
Email : <input type="text" name="email"><br/>
Message : <textarea name="message"></textarea><br/>
<input type="submit" name="sb" id="sb" value="Send">
</form>

And here it is the processing side


if(isset($_POST['submit'])) {

if($_POST['fullname'] == "" || $_POST['email'] == "" || $_POST['message'] == "")
print "Fields are mandatory";
}else{
$to = "youremail";
$from = $_POST['email'];
$subject = "contact form";
$message = $_POST['message'];
mail($to, $subject, $message);
}
This entry was posted in Usefull PHP and tagged , , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>