2014-03-06 164 views
0

我需要的是知道爲什麼我的表單不會發送它只是不斷髮送我相同的通用錯誤,一切都相匹配我認爲定期exspressions是問題,但林不知道...
形式的代碼是:我的PHP表單不會工作,我不知道爲什麼

<!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._%-][email protected][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

+1

什麼是_The相同的通用錯誤_? – putvande

+0

你有什麼嘗試?什麼是錯誤?它是什麼時候發生的?我們可以問一些很多問題... –

+0

縮小問題範圍。刪除代碼塊直到問題開始。 – Brad

回答

0

重寫

!isset ($_POST['DOB']) || 
!isset($_POST['comment'])) 

!isset ($_POST['DOB'])) 

你的HTML沒有一個註釋輸入欄。

1

您正在檢查不存在的name="comment"表單字段。
所以,你要麼需要與name="comment"添加一個字段到您的form或刪除|| !isset($_POST['comment'])

相關問題