<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3c.org/TR/html4/strict.dtd">
<html>
<head>
<title>My mailtastic contact page</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<?php
if($_SERVER['REQUEST_METHOD'] === "GET") {
?>
<form method="post" action="">
<fieldset>
<legend>Mail me</legend>
<label>Your E-mail Address<br><input type="text" name ="from"></label>
<br>
<label>Subject<br><input type="text" name ="subject"></label>
<br>
<label>Message<br><textarea name="message" rows="5" cols="60"></textarea></label>
<br>
<input type="submit" value="Send Mail">
</fieldset>
</form><?php
} elseif($_SERVER['REQUEST_METHOD'] === "POST") {
/*
Please note that this example code is severely flawed and should never be put to actual use.
*/
$mail_accepted = NULL;
$mail_accepted = mail("me" , $_POST['subject'] , $_POST['message'] , "From: " . $_POST['from'] . "\r\n");
if($mail_accepted === TRUE) {
?>
<p>Thank you. Your mail has been accepted for delivery.</p>
<?php
} else {
?>
<p>Sorry. Your mail has not been accepted for delivery.</p>
<?php
}
}
?>
</body>
</html>

Find a programming school near you