验证表单以打开新表单以发送电子邮件,电子邮件不发送 - PHP

时间:2014-10-28 18:56:13

标签: php email

我正在设置一个表单,根据数据库验证您的OrderID是否有效,一旦确定它是有效的,则会显示另一个允许您发送电子邮件订单的表单。

但是我遇到了一些问题,我的验证工作正常,但是电子邮件没有发送,我认为只是一个小错误,但我已经能够完全把我的数字放在上面了。

<div class="my-table-cell">
  <?php if (!isset($_POST["id-validate"])) { ?>
  <form id="xpress_ordr_form" method="post">
    <div style="display:inline-block;"><label for="orderid">OrderID:<span>*</span></label><input type="text" name="orderid" required="required" value="" /></div><input type="submit" name="id-validate" value="Validate" style="display:inline;" />
  </form>
    <?php } else { 
      $orderid = $_POST["orderid"];

      $servername = "servername";
      $username = "username";
      $password = "password";
      $dbname = "dbname";

      $conn = new mysqli($servername, $username, $password, $dbname);
      // Check connection
      if ($conn->connect_error) {
        die("We are experiencing technical difficulties at this time. Sorry for the inconvenience.");
      }

      $sql = "SELECT * FROM 8su1cb_xpress_userid WHERE xpress_orderid='". mysqli_real_escape_string($conn, $orderid) ."'";
      $result = mysqli_query($conn,$sql);

      if (mysqli_num_rows($result) > 0) {
        if (!isset($_POST["order_submit"])) { ?>
          <form id="xpress_ordr_form" method="post">
            <div style="display:none"><label for="emailadd">Email:<span>*</span></label><input type="text" name="emailadd" value="<?php $current_user = wp_get_current_user(); _e( $current_user->user_email ); ?>" required="required" /></div>
            <div style="display:none"><label for="username">Username:<span>*</span></label><input type="text" name="username" value="<?php $current_user = wp_get_current_user(); _e( $current_user->user_login ); ?>" required="required" /></div>
            <div><label for="orderid">OrderID:<span>*</span></label><input type="text" name="orderid" required="required" value="" /></div>
            <div><label for="ordermessage">Order:<span>*</span></label><textarea rows="5" cols="60" name="ordermessage" required="required"></textarea></div><div><input type="submit" name="order_submit" value="Place Order" /></div>
          </form>
        <?php } else {
          $from = $_POST["emailadd"];
          $wpcurntusername = $_POST["username"];
          $orderid = $_POST["orderid"];
          $orderplace = $_POST["ordermessage"];
          $orderplace = wordwrap($orderplace, 70);
          mail("webmaster@mrcool.com",$wpcurntusername,$orderid,$orderplace,"From: $from\n");
          echo '<p style="color:green;">Your order has been sent.</p>';
        }
      } else { ?>
        <form id="xpress_ordr_form" method="post">
          <div style="display:inline-block;"><label for="orderid">OrderID:<span>*</span></label><input type="text" name="orderid" required="required" value="" /></div><input type="submit" name="id-validate" value="Validate" style="display:inline;" /><p style="color:red;"><b>OrderID</b> not valid.</p>
        </form>
      <?php }

      $conn->close();
    }
    ?>
</div>

0 个答案:

没有答案