21,886
社区成员
发帖
与我相关
我的任务
分享
<?php ob_start(); ?>
<?php
date_default_timezone_set('Asia/Hong_Kong');
ini_set("sendmail_from","*****@yahoo.com");
ini_set("SMTP","smtp.wtt-mail.com");
$myemail = "**********@yahoo.com";
$company = check_input($_POST['company'], "Please enter your company's name");
$person = check_input($_POST['person'], "Please enter your name");
$tel = check_input($_POST['tel'], "Please enter your contact number");
$email = check_input($_POST['email'], "Please enter your E-mail");
$subject = "Online Enquiry";
if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/", $email))
{
show_error("E-mail address not valid");
}
if (!preg_match("/^(https?:\/\/+[\w\-]+\.[\w\-]+)/i", $website))
{
$website = '';
}
$message = "Hello!
Contact form has been submitted by:
Company Name: $company
Contact Person: $person
Tel: $tel
E-mail: $email
Content:
$content
End of message
";
mail($myemail,$subject,$message);
header('location:ThankYou.html');
exit();
function check_input($data, $problem='')
{
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
if ($problem && strlen($data) == 0)
{
show_error($problem);
}
return $data;
}
function show_error($myError)
{
?>
<html>
<head>
<title>Order form error</title>
<style type="text/css">
.style2 {
text-align: center;
border-width: 0px;
}
</style>
</head>
<body>
<MARQUEE direction="right" hspace="200" vspace="50" behavior="alternate">
<H2><b>Please correct the following error:</b><br /><H2>
<H2><?php echo $myError; ?><H2>
</MARQUEE>
<p>
<p class="MsoNormal" align="center">
<input type="button" value=" Back to previous page " onclick="history.back()">
<p class="MsoNormal" align="center">
</p>
</body>
</html>
<?php
exit();
}
ob_end_flush();
?>