2013-08-16 39 views
-4
 <?php 
     date_default_timezone_set('America/New_York'); 

      $to = "[email protected]"; 
      $subject = "New Membership Sign Up"; 
      $message = "First Name:" $_POST['one']; 
        "Last Name:" $_POST['two']; 
        "Email:" $_POST['three']; 
        "Password:" $_POST['four']; 
        "Phone:" $_POST['five']; 
        "Address 1:" $_POST['six']; 
        "Address 2:" $_POST['seven']; 
        "Pick Up City:" $_POST['eight']; 
        "State:" $_POST['nine']; 


      mail($to, $subject, $message); 
     ?> 

任何人都可以告訴我這段代碼有什麼問題嗎?形式似乎不發送,標記一切它應該,但不知道爲什麼它不工作這個send.php怎麼了?

這是形式的方式,

<table width="551" border="0" cellspacing="0" cellpadding="3"> 
      <form method="post" action="send.php"> 
       <tr> 
       <td width="108" class="TextAB"><div align="right"><strong>First Name:</strong></div></td> 
       <td width="431"><label> 
        <div align="left"> 
        <input name="one" type="text" id="001" size="50"/> 
        </div> 
       </label></td> 
       </tr> 
       <tr> 
       <td><div align="right"><span class="TextAB"><strong>Last Name:</strong></span></div></td> 
       <td><div align="left"> 
        <input name="two" type="text" id="002" size="50" /> 
       </div></td> 
       </tr> 
       <tr> 
       <td><div align="right"><span class="TextAB"><strong>Email:</strong></span></div></td> 
       <td><div align="left"> 
        <input name="three" type="text" id="textfield3" size="50" /> 
       </div></td> 
       </tr> 
       <tr> 
       <td><div align="right"><span class="TextAB"><strong>Password:</strong></span></div></td> 
       <td><div align="left"> 
        <input name="four" type="text" id="textfield4" size="50" /> 
       </div></td> 
       </tr> 
       <tr> 
       <td><div align="right"><span class="TextAB"><strong>Phone:</strong></span></div></td> 
       <td><div align="left"> 
        <input name="five" type="text" id="textfield5" size="30" /> 
       </div></td> 
       </tr> 
       <tr> 
       <td valign="top"><div align="right"><span class="TextAB"><strong>Address 1:</strong></span></div></td> 
       <td><div align="left"> 
        <textarea name="six" cols="50" rows="3" wrap="virtual" id="textfield6"></textarea> 
        <br /> 
        <span class="TextA style1">Please fill out full address, building number, street, city,state &amp; zip</span></div></td> 
       </tr> 
       <tr> 
       <td><div align="right"><span class="TextAB"><strong>Address 2:</strong></span></div></td> 
       <td><div align="left"> 
        <input name="seven" type="text" id="textfield7" size="50" /> 
       </div></td> 
       </tr> 
       <tr> 
       <td><div align="right"><span class="TextAB"><strong>Pick-Up City:</strong></span></div></td> 
       <td><div align="left"> 
        <select name="eight" id="select"> 
        <option value="Malabar">Malabar</option> 
        <option value="Ocala">Ocala</option> 
        <option value="Orlando">Orlando</option> 
        <option value="Orlando - Charles Schwab">Orlando - Charles Schwab</option> 
        <option value="West Palm Beach">West Palm Beach</option> 
        </select> 
       </div></td> 
       </tr> 
       <tr> 
       <td><div align="right"><span class="TextAB"><strong>State:</strong></span></div></td> 
       <td><div align="left"> 
        <select name="nine" id="select2"> 
        <option value="Florida">Florida</option> 
        </select> 
       </div></td> 
       </tr> 
       <tr> 
       <td><div align="left"></div></td> 
       <td><div align="left"></div></td> 
       </tr> 
       <tr> 
       <td><div align="left"></div></td> 
       <td><label> 
        <div align="left"><a href="#" class="TextE" onclick="javascript:Terms();document.getElementById('ch1').disabled=false;document.getElementById('ch2').disabled=false;"/><span class="TextE"><strong>Click to read MEMBER AGREEMENT<br /> 
          <br /> 
        </strong></span></a> 
        <input type="checkbox" id="ch1" name="ch1" value="" disabled/> 
        <span class="TextE"><strong>I have read the Terms of Agreement</strong></span></div> 
       </label></td> 
       </tr> 
      </table> 
      </td> 
      <td width="129" valign="bottom"><INPUT TYPE="image" name="ch2" id="ch2" value="" SRC="images/submitbutton.jpg" WIDTH="111" HEIGHT="136" BORDER="0" ALT="SUBMIT" disabled></td> 
      </tr> 
     </table></td> 
     </tr> 
    </table> </form></td></tr> 

任何幫助,將不勝感激

爲什麼當我嘗試提交它不會去我的電子郵件?

我確實已設置爲提交時它將轉到另一個頁面,他們支付會員費 但我希望從表單中獲得的信息轉到我自己,以便我可以看到誰加入了網站。

+0

推薦閱讀:http://php.net/manual/en/language.operators.string.php – vee

回答

8
 $message = "First Name:" $_POST['one']; 
       "Last Name:" $_POST['two']; 
       "Email:" $_POST['three']; 
       "Password:" $_POST['four']; 
       "Phone:" $_POST['five']; 
       "Address 1:" $_POST['six']; 
       "Address 2:" $_POST['seven']; 
       "Pick Up City:" $_POST['eight']; 
       "State:" $_POST['nine']; 

應該是:

 $message = "First Name:" . $_POST['one'] . "\n" . 
       "Last Name:" . $_POST['two'] . "\n" . 
       "Email:" . $_POST['three'] . "\n" . 
       "Password:" . $_POST['four'] . "\n" . 
       "Phone:" . $_POST['five'] . "\n" . 
       "Address 1:" . $_POST['six'] . "\n" . 
       "Address 2:" . $_POST['seven'] . "\n" . 
       "Pick Up City:" . $_POST['eight'] . "\n" . 
       "State:" . $_POST['nine']; 

不是你讓PHP解析錯誤?你的代碼甚至沒有接近有效的語法。字符串使用.連接在一起,而不僅僅是將它們放在一起。每行之間有一個;,結束了作業。其餘的行不是任何有效的PHP語句。

您需要了解基本的PHP編碼。

+0

TY芽,它現在的職位,但只有一點從信息該字段不會顯示任何輸入的東西,只有我看到的是標題,但帖子'一'等等它顯示爲空 –

+0

是'send.php'也包含表單的腳本? – Barmar

+0

沒有表單在另一個名爲join.php的php文件中 –

0

使用下面

<?php 
    date_default_timezone_set('America/New_York'); 

     $to = "[email protected]"; 
     $subject = "New Membership Sign Up"; 
     $message = "First Name:".$_POST['one']; 
     $message.= "Last Name:". $_POST['two']; 
     $message.= "Email:". $_POST['three']; 
     $message.= "Password:". $_POST['four']; 
     $message.= "Phone:" .$_POST['five']; 
     $message.= "Address 1:" .$_POST['six']; 
     $message.= "Address 2:" .$_POST['seven']; 
     $message.= "Pick Up City:" .$_POST['eight']; 
     $message.= "State:" .$_POST['nine']; 

,也有在你的郵件功能的問題。而您沒有使用$ header。使用郵件功能象下面這樣: -

 $headers = 'From: [email protected]' . "\r\n" . 
       'Reply-To: [email protected]' . "\r\n" . 
       'X-Mailer: PHP/' . phpversion(); 

     mail($to, $subject, $message, $headers); 
    ?> 
+0

headers參數是可選的。 – Barmar

+0

@Barmar是的,你是對的。但你有沒有試過上面的代碼? – ripa

+0

我還沒有試過任何代碼。順便說一句,你錯過了所有'$ message'賦值中字符串連接的'.',就像OP的原始代碼一樣。 – Barmar