Файл mail.html
CODE:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
<title>mail me</title>
</head>
<body>
<style type="text/css">
body,td,th {
font-family: Arial, Helvetica, sans-serif;
font-size: 10px;
color: #000000;
font-weight: bold;
}
h3 {
font-size: 11px;
}
</style>
<table border="0" cellpadding="2" cellspacing="1" bgcolor="#000000">
<form action="mail.php" method="post">
<tr bgcolor="#FFFFFF">
<td>.: to</td>
<td><input type="text" name="to"></td>
</tr>
<tr bgcolor="#FFFFFF">
<td>.: subject</td>
<td><input type="text" name="subject"></td>
</tr>
<tr bgcolor="#FFFFFF">
<td>.: message</td>
<td><textarea name="message" cols="50" rows="10">//from somebody</textarea></td>
</tr>
<tr bgcolor="#FFFFFF">
<td><input type="submit" name="go" value="submit"></td>
<td><input type="reset" name="reset" value="reset"></td>
</tr>
</form>
</table>
</body>
</html>
Файл mail.php
CODE:
<?
$error='';
if($_POST['go']) {
if(empty($_POST['to'])) {
$error=$error.'<li>to who?<BR>';
}
if (!preg_match('/[0-9a-z_]+@[0-9a-z_^\.]+\.[a-z]{2,3}/i', $_POST['to'])) {
$error=$error.'<li>not correct email address! enter something like somebody@server.com<BR>';
}
if(empty($_POST['subject'])) {
$error=$error.'<li>what is the subject?<BR>';
}
if(empty($_POST['message'])) {
$error=$error.'<li>what is the message?<BR>';
}
if(empty($error)) {
mail($_POST['to'],$_POST['subject'],$_POST['message']);
}
if(!empty($error)) {
print 'there are some errors here: <BR><ul>'.$error.'</ul>';
}
}
?>
Будут вопросы - спрашивай. |