表单未发送到feenix mysql

carvr3hs  于 2021-06-25  发布在  Mysql
关注(0)|答案(0)|浏览(193)

html格式:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8" />
  <title>ShipOnline System</title>
</head>
<body>  
  <h1>ShipOnline System Request Page</h1>
    <form method="post" action="request.php">
        <fieldset>
      <fieldset>
        <legend>Item Information:</legend>
        <p><label for="description">Description:</label> 
            <input type="text" name= "description" id="description" maxlength="100" size="20"  required="required"/></p>

        <p><label for="weight">Weight (kg):</label> 
          <select name="weight" id="weight" required="required">
            <option value="">Please Select</option>         
            <option value="weight">0-2</option>
            <option value="weight">3</option>
            <option value='weight'>4</option>
            <option value='weight'>5</option>
            <option value='weight'>6</option>
            <option value='weight'>7</option>
            <option value='weight'>8</option>
            <option value='weight'>9</option>
            <option value='weight'>10</option>
            <option value='weight'>11</option>
            <option value='weight'>12</option>
            <option value='weight'>13</option>
            <option value='weight'>14</option>
            <option value='weight'>15</option>
            <option value='weight'>16</option>
            <option value='weight'>17</option>
            <option value='weight'>18</option>
            <option value='weight'>19</option>
            <option value='weight'>20</option>
          </select></p>
      </fieldset>
      <fieldset>
        <legend>Pick-up Information:</legend>
        <p><label for="pickupAddress">Street Address:</label> 
          <input type="text" name= "pickupAddress" id="pickupAddress" maxlength="40" size="30" required="required"/></p>

        <p><label for="pickupSuburb">Suburb:</label> 
          <input type="text" name= "pickupSuburb" id="pickupSuburb" maxlength="40" size="20" required="required"/></p>

        <p><label for="date">Preferred date:</label> 
          <select name="day" id="date" required="required">
            <option value="">Day</option>         
            <option value="day">1</option>
            <option value="day">2</option>
            <option value="day">3</option>
            <option value='day'>4</option>
            <option value='day'>5</option>
            <option value='day'>6</option>
            <option value='day'>7</option>
            <option value='day'>8</option>
            <option value='day'>9</option>
            <option value='day'>10</option>
            <option value='day'>11</option>
            <option value='day'>12</option>
            <option value='day'>13</option>
            <option value='day'>14</option>
            <option value='day'>15</option>
            <option value='day'>16</option>
            <option value='day'>17</option>
            <option value='day'>18</option>
            <option value='day'>19</option>
            <option value='day'>20</option>
            <option value='day'>21</option>
            <option value='day'>22</option>
            <option value='day'>23</option>
            <option value='day'>24</option>
            <option value='day'>25</option>
            <option value='day'>26</option>
            <option value='day'>27</option>
            <option value='day'>28</option>
            <option value='day'>29</option>
            <option value='day'>30</option>
            <option value='day'>31</option>
          </select>
          <select name="month" id="date" required="required">
            <option value="">Month</option> 
            <option value='month'>1</option>
            <option value='month'>2</option>
            <option value='month'>3</option>
            <option value='month'>4</option>
            <option value='month'>5</option>
            <option value='month'>6</option>
            <option value='month'>7</option>
            <option value='month'>8</option>
            <option value='month'>9</option>
            <option value='month'>10</option>
            <option value='month'>11</option>
            <option value='month'>12</option>
          </select>
          <select name="year" id="date" required="required">
            <option value="">Year</option> 
            <option value='year'>2018</option>
            <option value='year'>2019</option>
            <option value='year'>2020</option>
            <option value='year'>2021</option>
          </select></p>

        <p><label for="time">Prefered time:</label> 
          <select name="time" id="time" required="required">
            <option value="">Please Select</option>         
            <option value="time">7:30-8:30</option>
            <option value="time">8:30-9:30</option>
            <option value="time">9:30-10:30</option>
            <option value="time">10:30-11:30</option>
            <option value="time">11:30-12:30</option>
            <option value="time">12:30-13:30</option>
            <option value="time">13:30-14:30</option>
            <option value="time">14:30-15:30</option>
            <option value="time">15:30-16:30</option>
            <option value="time">16:30-17:30</option>
            <option value="time">17:30-18:30</option>
            <option value="time">18:30-19:30</option>
            <option value="time">19:30-20:30</option>
          </select></p>
      </fieldset>
      <fieldset>
        <legend>Delivery Information:</legend>
        <p><label for="receiver">Receiver Name:</label> 
          <input type="text" name= "receiver" id="receiver" maxlength="40" size="20" pattern="^[a-zA-Z ]+$" required="required"/></p>

        <p><label for="deliveryAddress">Street Address:</label> 
          <input type="text" name= "deliveryAddress" id="deliveryAddress" maxlength="40" size="30" required="required"/></p>

        <p><label for="deliverySuburb">Suburb:</label> 
          <input type="text" name= "deliverySuburb" id="deliverySuburb" maxlength="40" size="20" required="required"/></p>

        <p><label for="state">State:</label> 
          <select name="state" id="state" required="required">
            <option value="">Please Select</option>         
            <option value="state">VIC</option>
            <option value="state">NSW</option>
            <option value="state">QLD</option>
            <option value="state">NT</option>
            <option value="state">WA</option>
            <option value="state">SA</option>
            <option value="state">TAS</option>
            <option value="state">ACT</option>
          </select></p>
      </fieldset>
      <br/>
      <input type= "submit" value="Request"/>
        </fieldset>
    </form>
    <p><a href="shiponline.php#shiponline">Home</a></p>
</body>
</html>

PHP:

<?php
  require_once ("settings.php"); //connection info
  $conn = @mysqli_connect($host,
    $user,
    $pwd,
    $sql_db
  );

  $requestID = trim($_POST["requestID"]);
  $customerID = trim($_POST["customerID"]);
  $requestDate = trim($_POST["requestDate"]);
  $description = trim($_POST["description"]);
  $weight = trim($_POST["weight"]);
  $pickupAddress = trim($_POST["pickupAddress"]);
  $pickupSuburb = trim($_POST["pickupSuburb"]);
  $date = trim($_POST["date"]);
  $time = trim($_POST["time"]);
  $receiver = trim($_POST["receiver"]);
  $deliveryAddress = trim($_POST["deliveryAddress"]);
  $deliverySuburb = trim($_POST["deliverySuburb"]);
  $state = trim($_POST["state"]);

  $sql_table="Request";
  $query = "insert into $sql_table (description, weight, pickupAddress, pickupSuburb, date, time, receiver, deliveryAddress, deliverySuburb, state) values ('$description', '$weight', '$pickupAddress', '$pickupSuburb', '$date', '$time', '$receiver', '$deliveryAddress', '$deliverySuburb', '$state')";
  //execute the query -we should really check to see if the batabase exists first.
  $result = mysqli_query($conn, $query);
  //checks if the exeution was succcessful
  if (!$result) {
      echo "<p class=\"wrong\">Something is wrong with your request please go back and check your details</p>";
      // would not show in a production script
    } else {
      // display an operation successful message
      echo "<p class=\"ok\">Thank you! Your request number is requestID. The cost is <cost>. We will pick-up the item at $time on $date.</p>";
    } // if successful query operation
    // close the database connection
  mysqli_close($conn);
   // if successful database connection
?>

我有一个类似的php文件,这一个完美的工作。我相信我一直收到这样的信息:“你的请求有问题,请回去检查你的详细信息”,因为“日期”,“时间”或是“重量”和“状态”的下拉框,但我尝试删除它们,没有任何改变,我一直得到有问题。我似乎不知道是什么原因导致表单无法成功发送。有人能试着找出错误吗?

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题