<html>
<head>
<title>Week #6 ~ Lestat</title>
<link rel="stylesheet" type="text/css" href="/css/scriptskewl.css">
</head>
<body>
This form will email a form to yourself
<?
if($_POST['action'] == "send_mail") {
$recipient = $_REQUEST['email'];
$email = $_REQUEST['email'];
$name = $_REQUEST['name'];
$subject = "Just a test from $name";
$body_of_email = "This is the contents of the email from $name";
$additional_headers = "From: $email";
if(ereg("([[:alnum:]\.\-]+)(\@[[:alnum:]\.\-]+\.+)", $email)) {
if(mail($recipient, $subject, $body_of_email, $additional_headers)){
print("mail successfully sent</body></html>");
}else{print("oops! something didnt work right above, check the syntax of your code");}
}else{print("oops it appears that $email is not in the correct email format please try again");
}
}else{
?>
<form METHOD=POST action="<? $PHP_SELF ?>">
<input type="hidden" name="action" value="send_mail">
Name: <input type="text" name="name"><br>
Your Email: <input type="text" name="email" size=40>
<input type="submit" value="Submit"></form>
<?}?>
<pre>
</pre>
<br>
<iframe src='wk6examplesrc.php' width='850' height='300'></iframe>
<br>
<a href='../index.html'>BACK</a>
</body>
</html>