这个send.php怎么了?

时间:2013-08-16 05:26:27

标签: php

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

          $to = "ry@cbpar.com"; 
          $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);
        ?>

任何人都可以告诉我这段代码有什么问题吗?表格似乎没有发送,标记了它应该的方式,但不确定为什么它不起作用

这是表格,

    <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>

任何帮助将不胜感激

为什么当我尝试提交时不会转到我的电子邮件?

我确实将它设置为提交时它将转到另一个页面,他们支付会员资格 但是我希望从表单中获取信息,这样我才能看到谁加入了网站。

2 个答案:

答案 0 :(得分: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编码。

答案 1 :(得分:0)

使用以下

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

      $to = "ry@cbpar.com"; 
      $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: webmaster@example.com' . "\r\n" .
                 'Reply-To: webmaster@example.com' . "\r\n" .
                 'X-Mailer: PHP/' . phpversion();

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