我已经多次从这个网站获得帮助,但这是我第一次需要发布我自己的细节。
我有一个 PHP 注册表单,我确信这是一个小问题,但我不知道我需要修复什么。所以,我很感激有人看过它。
<?php
if(isset($_POST['email'])) {
// EDIT THE 2 LINES BELOW AS REQUIRED
$email_to = "c@d.com";
$email_subject = "Form Submitted";
$email_from = "c@d.com";
function died($error) {
// your error code can go here
echo "We are very sorry, but there were error(s) found with the form you submitted. ";
echo "These errors appear below.<br /><br />";
echo $error."<br /><br />";
echo "Please go back and fix these errors.<br /><br />";
die();
}
// validation expected data exists
if(!isset($_POST['Agency']) ||
!isset($_POST['AgencyPhone'])) {
died('We are sorry, but there appears to be a problem with the form you submitted.');
}
$Agency = $_POST['Agency']; // required
$AgencyPhone = $_POST['AgencyPhone']; // required
$contact = $_POST['contact']; // not required
...this goes on for quite some time...
$Zip = $_POST['Zip']; // not required
$error_message = "";
$string_exp = "/^[A-Za-z .'-]+$/";
if(!preg_match($string_exp,$Agency)) {
$error_message .= 'The Agency Name you entered does not appear to be valid.<br />';
}
if(strlen($AgencyPhone) < 2) {
$error_message .= 'The Agency Phone you entered does not appear to be valid.<br />';
}
$email_message = "You received a message from your site!\n\n";
function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}
$email_message="
Class: ".$contact."
Dates: ".$Dates." through ".$through."
Location: ".$Location."
Fee: ".$Fee.", ".$Rate."
Students:
1: ".$Last1.", ".$First1.", ".$Email1.", ".$Phone1."\n;
2: ".$Last2.", ".$First2.", ".$Email2.", ".$Phone2."\n;
3: ".$Last3.", ".$First3.", ".$Email3.", ".$Phone3."\n;
4: ".$Last4.", ".$First4.", ".$Email4.", ".$Phone4."\n;
5: ".$Last5.", ".$First5.", ".$Email5.", ".$Phone5."\n;
Agency: ".$Agency.";
Mailing: ".$Mailing.";
City: ".$City.";
Zip: ".$Zip.";
Agency Phone: ".$AgencyPhone.";
"
// create email headers
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);
?>
...Then, I have the content of the process page...
<!-- Do not change anything below this line -->
<?php
}
?>
所以,错误就在这一行。
$headers = 'From: '.$email_from."\r\n".
或者,无论如何,一个错误是。缺少什么,或者我需要添加什么?感谢您提供的任何帮助。对此,我真的非常感激。
我的表格是:
<form action="Rprocess.php" method="post" enctype="multipart/form-data" class="body">
<p><span class="title">Enter Class Date, Location and Fee</span><br />
<span class="style3">for which you are registering</span>:</p>
<p align="left" class="style1">Dates:
<input type="text" name="Dates" size="15" id="Dates" />
through
<input type="text" name="through" size="15" id="through" />
</p>
<p align="left" class="style1">Location:
<input type="text" name="Location" size="48" id="Location" />
</p>
<div class="field form-inline radio2">
<table width="100%" border="0" cellspacing="2">
<tr>
<td width="509"><span class="style1">Registration Fee:
<input name="Fee" type="text" id="Fee" value="$" size="15" />
per student</span></td>
</tr>
</table>
<p class="style1">Please fill in fields below.<br />
<span class="style3">(Confirmation e-mail will be forwarded to attendee and Registrant Agency upon receipt.)</span></p>
<p><span class="title">Student Information</span>:</p>
<table width="100%" border="0" cellspacing="2">
<tr>
<td width="25%"><span class="style1">Last</span></td>
<td><span class="style1">First</span></td>
<td width="25%"><span class="style1">E-mail</span></td>
<td width="25%"><span class="style1">Phone</span></td>
</tr>
<tr>
<td width="25%"><span class="style1">
<input type="text" name="Last1" size="15" id="Last1" />
</span></td>
<td><span class="style1">
<input type="text" name="First1" size="15" id="First1" />
</span></td>
<td width="25%"><span class="style1">
<input type="text" name="Email1" size="15" id="Email1" />
</span></td>
<td width="25%"><span class="style1">
<input type="text" name="Phone1" size="15" id="Phone1" />
</span></td>
</tr>
<tr>
<td><span class="style1">
<input type="text" name="Last2" size="15" id="Last2" />
</span></td>
<td><span class="style1">
<input type="text" name="First2" size="15" id="First2" />
</span></td>
<td><span class="style1">
<input type="text" name="Email2" size="15" id="Email2" />
</span></td>
<td><span class="style1">
<input type="text" name="Phone2" size="15" id="Phone2" />
</span></td>
</tr>
<tr>
<td><span class="style1">
<input type="text" name="Last3" size="15" id="Last3" />
</span></td>
<td><span class="style1">
<input type="text" name="First3" size="15" id="First3" />
</span></td>
<td><span class="style1">
<input type="text" name="Email3" size="15" id="Email3" />
</span></td>
<td><span class="style1">
<input type="text" name="Phone3" size="15" id="Phone3" />
</span></td>
</tr>
<tr>
<td><span class="style1">
<input type="text" name="Last4" size="15" id="Last4" />
</span></td>
<td><span class="style1">
<input type="text" name="First4" size="15" id="First4" />
</span></td>
<td><span class="style1">
<input type="text" name="Email4" size="15" id="Email4" />
</span></td>
<td><span class="style1">
<input type="text" name="Phone4" size="15" id="Phone4" />
</span></td>
</tr>
<tr>
<td><span class="style1">
<input type="text" name="Last5" size="15" id="Last5" />
</span></td>
<td><span class="style1">
<input type="text" name="First5" size="15" id="First5" />
</span></td>
<td><span class="style1">
<input type="text" name="Email5" size="15" id="Email5" />
</span></td>
<td><span class="style1">
<input type="text" name="Phone5" size="15" id="Phone5" />
</span></td>
</tr>
</table>
<p><span class="title">Registrant Agency Information</span>:</p>
<p align="left" class="style1"><strong>Agency Name*</strong>:
<input type="text" name="Agency" size="48" id="Agency" />
</p>
<p align="left" class="style1">Mailing Address:
<input type="text" name="Mailing" size="48" id="Mailing" />
</p>
<p align="left" class="style1">City:
<input type="text" name="City" size="48" id="City" />
Zip:
<input type="text" name="Zip" size="15" id="Zip" />
</p>
<p align="left" class="style1"><strong>Phone*</strong>:
<input name="AgencyPhone" type="text" id="AgencyPhone" size="48" />
</p>
<p align="center"><input type="submit" value="Submit" /></p>
</form>
我还删除了一组单选按钮(名为 Rate)和复选框(名为 Fee)。一次一个问题...