Web Design & Development
[ Web Design & Development Topics ]
Ok, that last sample was cool and all, but what if you want to shoot of an email? Well, try this:
Lets make another very simple form first (and call it sendform.html or whatever):
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Form to Email</title>
</head>
<body>
<form method="post" action="sendmail.php">
<p>Email:
<input name="email" type="text" />
<br />
Message:<br />
<textarea name="message" rows="15" cols="40">
</textarea>
<br />
</p>
<p>
<input type="submit" value="Submit either plain text or HTML source code" />
</p>
</form>
</body>
</html>
Great! Now we just need to make the PHP file to shoot off the email (which we called sendmail.php above but we could've called anything):
<?
$email = $_REQUEST['email'] ;
$message = $_REQUEST['message'] ;
/* recipients */
$to = "arendtan@uvsc.edu" . ", " ; // note the comma
$to .= "anne_and_alex@earthlink.net";
/* To send HTML mail, you can set the Content-type header. */
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
mail( $to, "ourdeskdrawer Test Page - HTML from box",
$message, $headers);
$headers .= "From: Email Form<$email>\r\n";
/* additional headers
$headers .= "Cc: birthdayarchive@example.com\r\n";
$headers .= "Bcc: birthdaycheck@example.com\r\n";
*/
echo "Thank you ".$_POST["email"]." for taking the time to complete this survey.<P>";
?>