<html>
<head>
<title>Max Design contact page</title>
<link href="mdstyle1.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="container">
<?php
$required = array("firstName" => "First Name",
"surname" => "Surname",
"email" => "Email Address",
"telephone" => "Telephone");
foreach($required as $field => $label) {
if (!$_POST[$field]) {
$warnings[$field] = "*";
}
}
if ($_POST["firstName"] &&
!ereg("[a-zA-Z]", $_POST["firstName"]))
$warnings["firstName"] = "Please check First Name for errors";
if ($_POST["surname"] &&
!ereg("[a-zA-Z]", $_POST["surname"]))
$warnings["surname"] = "Please check Surname for errors";
if ($_POST["email"] &&
!ereg("^[^@]+@([a-z\-]+\.)+[a-z]{2,4}$", $_POST["email"]))
$warnings["email"] = "Please check email for errors";
if ($_POST["telephone"] &&
!ereg("[0-9]", $_POST["telephone"]))
$warnings["telephone"] = "Please check Telephone for errors";
if (count($warnings) > 0) {
// sets the description of the sections of the form and must have an entry for each form element
$description = array();
$description{"firstName"} = "First Name";
$description{"surname"} = "Surname";
$description{"telephone"} = "Telephone Number";
$description{"email"} = "Email Address";
?>
<div class="main-paragraph">
<form method="POST" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
<br />
<div class="warnings"> * Please fill in these boxes </div>
<br />
<br />
<TABLE BORDER=0>
<TR>
<TD><label>First Name</label>
</TD><TD><INPUT TYPE=TEXT SIZE=30 NAME="firstName"
VALUE="<?php echo $_POST["firstName"];?>"></TD>
<TD><div class="warnings"><?php echo $warnings["firstName"];?></div></TD>
</TR>
<TR>
<TD><label>Surname</label>
</TD><TD><INPUT TYPE=TEXT SIZE=30 NAME="surname"
VALUE="<?php echo $_POST["surname"];?>"></TD>
<TD><div class="warnings"><?php echo $warnings["surname"];?></div></TD>
</TR>
<TR>
<TD><label>Email Address</label>
</TD>
<TD><INPUT TYPE=TEXT SIZE=30 NAME="email"
VALUE="<?php echo $_POST["email"];?>"></TD>
<TD><div class="warnings"><?php echo $warnings["email"];?></div></TD>
</TR>
<TR>
<TD><label>Telephone</label>
</TD>
<TD><INPUT TYPE=TEXT SIZE=15 NAME="telephone"
VALUE="<?php echo $_POST["telephone"];?>"></TD>
<TD><div class="warnings"><?php echo $warnings["telephone"];?></div></TD>
</TR>
</TABLE>
<br />
<INPUT TYPE=SUBMIT VALUE="Send Enquiry">
</FORM>
</div> <!-- end of main paragraph -->
<?php
}
else { // start of send section
//stuff that goes to the enquirer
$clients_email = "From: sales@rmrc.co.uk";
$headers2 = "From: simon@maxdesign.org.uk";
$subject2 = "Thank you for contacting MAX Design";
$autoreply = "Thank you for contacting MAX Design. We will get back to you as soon as possible,
\n usualy within 48 hours. If you have any more questions,
\n please consult our website at www.maxdesign.org.uk/index";
//prints out each field's title and contents in turn each on new line
$body = "A quote request from the website:\n\n";
foreach($_POST as $description => $value) {
$body .= sprintf("%s = %s\n", $description, $value);
}
mail($email, $subject2, $autoreply, $headers2);
mail("sim.on@hotmail.co.uk", "MAX Design website enquiry", $body, $email);
header( "Location: http://www.maxdesign.org.uk/thank-you-for-quote-max-design.html" );
} //end of send section
?>
</div><!--end of container/wrapper div -->
</body>
</html>
我正在尝试从客户端网站发送一个格式粗糙的电子邮件(我试图使用$ description变量进行格式化,但这也不起作用),但脚本不会发送它使用
西蒙
答案 0 :(得分:0)
您正在向您的$email
发送一个名为 mail()
的变量,该变量在代码中根本没有定义。这就是为什么你的邮件没有被发送。见下文
mail($email, $subject2, $autoreply, $headers2);
//^^^^^ Undefined variable
解决方案:将$email
设置为某个电子邮件。