dourukeng5302 2015-04-01 10:12
浏览 8
已采纳

为什么我的表单会占用每个条目并将它们传递给除了最后一个之外的php?

I am using the following form to try and take the data to update my database.

<form id="dataForm" action="addToProducts.php" method="post">
  <div>
    <lable >Product Name:</lable>
    <input class="inputForm" id="addName" type="text" name="Name">
  </div>
  <div>
    <lable>Description:</lable>
    <input class="inputForm" id="addDescription" type="text" name="description">
  </div>
  <div>
    <lable>Price:</lable>
    <input class="inputForm" id="addPrice" type="text" name="Price">
  </div>
  <div>
    <lable>Quantity:</lable>
    <input class="inputForm" id="addQuantity" type"text" name"quantity">
  </div> 
  <div id="theSubmit">
    <button id="addButton">Submit</button>
  </div>
  </form>

I then am using the following php code to update the database. When i run the following code by clicking submit it passes all the values into the database apart from the quantity and leaves it at 0 and i can not work out why after several hours of looking at it. Here is the php code..

$Name = $_POST['Name'];
     $Description = $_POST['description'];
     $Price = $_POST['Price'];
     $Quantity = $_POST['quantity'];

     $sql = "INSERT INTO PRODUCTS (P_Name, P_Description, P_Price, P_Quantity) VALUES ('$Name', '$Description', '$Price', '$Quantity') ";
     $conn->exec($sql);

any pointers would be a great help

  • 写回答

4条回答 默认 最新

  • donglu8779 2015-04-01 10:15
    关注

    you have missed an '=' here

    <lable>Quantity:</lable>
        <input class="inputForm" id="addQuantity" type"text" name"quantity">
    

    changed to

    <lable>Quantity:</lable>
        <input class="inputForm" id="addQuantity" type="text" name="quantity">
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 STM32无法向设备写入固件
  • ¥15 使用ESP8266连接阿里云出现问题
  • ¥15 BP神经网络控制倒立摆
  • ¥20 要这个数学建模编程的代码 并且能完整允许出来结果 完整的过程和数据的结果
  • ¥15 html5+css和javascript有人可以帮吗?图片要怎么插入代码里面啊
  • ¥30 Unity接入微信SDK 无法开启摄像头
  • ¥20 有偿 写代码 要用特定的软件anaconda 里的jvpyter 用python3写
  • ¥20 cad图纸,chx-3六轴码垛机器人
  • ¥15 移动摄像头专网需要解vlan
  • ¥20 access多表提取相同字段数据并合并