我需要的是知道为什么我的表单不会发送它只是不断发送给我相同的一般错误,一切都匹配我认为常规的exspressions是问题,但我不确定...
表格代码是:
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>register</title>
<link rel="stylesheet" href="../css/eight.css"/>
<!--<script type="text/javascript" src="../js/valid.js"></script>-->
</head>
<body>
<a href="../home.html"><div class="tile amarelo">
<span class="t">Home</span><br/>
</div></a><BR><BR>
<center>
<form name="signup" method="post" action="send_form_member.php">
<table width="450px">
<tr>
<td valign="top">
<label for="firstName">First Name *</label>
</td>
<td valign="top">
<input type="text" name="firstName" maxlength="50" size="30">
</td>
</tr>
<tr>
<td valign="top"">
<label for="lastName">Last Name *</label>
</td>
<td valign="top">
<input type="text" name="lastName" maxlength="50" size="30">
</td>
</tr>
<tr>
<td valign="top">
<label for="address">street address *</label>
</td>
<td valign="top">
<input type="text" name="address" maxlength="80" size="30">
</td>
</tr>
<tr>
<td valign="top">
<label for="city">city *</label>
</td>
<td valign="top">
<input type="text" name="city" maxlength="80" size="30">
</td>
</tr>
<tr>
<td valign="top">
<label for="state">state *</label>
</td>
<td valign="top">
<input type="text" name="state" maxlength="80" size="30">
</td>
</tr>
<tr>
<td valign="top">
<label for="zip">zip *</label>
</td>
<td valign="top">
<input type="text" name="zip" maxlength="80" size="30">
</td>
</tr>
<tr>
<td valign="top">
<label for="phoneNumber">phone number *</label>
</td>
<td valign="top">
<input type="text" name="phoneNumber" maxlength="80" size="30">
</td>
</tr>
<tr>
<td valign="top">
<label for="email">Email Address *</label>
</td>
<td valign="top">
<input type="text" name="email" maxlength="80" size="30">
</td>
</tr>
<tr>
<td valign="top">
<label for="username">Username</label>
</td>
<td valign="top">
<input type="text" name="username" maxlength="30" size="30">
</td>
</tr>
<tr>
<td valign="top">
<label for="password">password *</label>
</td>
<td valign="top">
<input type="password" name="password" maxlength="30" size="30">
</td>
</tr>
<tr>
<td valign="top">
<label for="DOB">DOB *(mm/dd/yyyy)</label>
</td>
<td valign="top">
<input type="text" name="DOB" maxlength="80" size="30">
</td>
</tr>
<tr>
<td colspan="2" style="text-align:center">
<input type="submit" value="Submit">
</td>
</tr>
</table>
</body>
</html>
php检查和电子邮件发件人是:
<?php
if(isset($_POST['email'])) {
$email_to = "my e-mail";
$email_subject = "Signed up";
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['firstName']) ||
!isset($_POST['lastName']) ||
!isset($_POST['email']) ||
!isset($_POST['phoneNumber']) ||
!isset($_POST ['address']) ||
!isset($_POST['city']) ||
!isset($_POST['state']) ||
!isset($_POST['zip']) ||
!isset ($_POST['username']) ||
!isset ($_POST['password']) ||
!isset ($_POST['DOB']) ||
!isset($_POST['comment'])) {
died('We are sorry, but there appears to be a problem with the form you submitted.');
}
$firstName = $_POST['firstName']; // required
$lastName = $_POST['lastName']; // required
$address = $_POST['address']; //reuired
$city = $_POST['city']; // required
$state = $_POST['state']; // required
$zip = $_POST['zip']; // required
$username = $_POST['username']; //required
$password = $_POST['password']; // required
$email_from = $_POST['email']; // required
$phoneNumber = $_POST['phoneNumber']; // required
$DOB = $_POST['DOB']; // required in JS but not php yet
$error_message = "";
$email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
if(!preg_match($email_exp,$email_from)) {
$error_message .= 'The Email Address you entered does not appear to be valid.<br />';
}
$string_exp = "/^[A-Za-z .'-]+$/";
if(!preg_match($string_exp,$firstName)) {
$error_message .= 'The First Name you entered does not appear to be valid.<br />';
}
if(!preg_match($string_exp,$lastName)) {
$error_message .= 'The Last Name you entered does not appear to be valid.<br />';
}
$string_exp = "/^[A-Za-z0-9.'-]+$/";
if(!preg_match($string_exp,$address)) {
$error_message .= 'The address you entered does not appear to be valid.<br />';
}
$string_exp = "/^[A-Za-z .'-]+$/";
if(!preg_match($string_exp,$city)) {
$error_message .= 'The city you entered does not appear to be valid.<br />';
}
$string_exp = "/^[A-Za-z .'-]+$/";
if(!preg_match($string_exp,$state)) {
$error_message .= 'The state you entered does not appear to be valid.<br />';
}
$string_exp = "/^[0-9 .'-]+$/";
if(!preg_match($string_exp,$zip)) {
$error_message .= 'The zip you entered does not appear to be valid.<br />';
}
$string_exp = "/^[0-9 .'-]+$/";
if(!preg_match($string_exp,$phoneNumber)) {
$error_message .= 'The phone number you entered does not appear to be valid.<br />';
}
$string_exp = "/^.*(?=.{8,})(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).*$/";
if(!preg_match($string_exp,$username)) {
$error_message .= 'The username you entered does not appear to be valid.<br />';
}
$string_exp = "/^.*(?=.{8,})(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).*$/";
if(!preg_match($string_exp,$password)) {
$error_message .= 'The password you entered does not appear to be valid.<br />';
}
if(strlen($error_message) > 0) {
died($error_message);
}
$email_message = "Form details below.\n\n";
function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}
$email_message .= "First Name: ".clean_string($firstName)."\n";
$email_message .= "Last Name: ".clean_string($lastName)."\n";
$email_message .= "Address: ".clean_string($address)."\n";
$email_message .= "city: ".clean_string($city)."\n";
$email_message .= "state: ".clean_string($state)."\n";
$email_message .= "zip: ".clean_string($zip)."\n";
$email_message .= "Email: ".clean_string($email_from)."\n";
$email_message .= "Phone number: ".clean_string($phoneNumber)."\n";
$email_message .= "Username: ".clean_string($username)."\n";
$email_message .= "password: ".clean_string($password)."\n";
$email_message .= "DOB: ".clean_string($DOB)."\n";
// 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);
?>
了解整个网站的想法请访问www.photofundesigns.com
答案 0 :(得分:1)
您正在检查不存在name="comment"
的表单字段
因此,您需要向name="comment"
添加form
字段或删除|| !isset($_POST['comment'])
答案 1 :(得分:0)
重写
!isset ($_POST['DOB']) ||
!isset($_POST['comment']))
作为
!isset ($_POST['DOB']))
您的html没有评论输入框。