要在php中发布以保存在数据库中的Jquery值

要在php中发布以保存在数据库中的Jquery值,php,jquery,json,posting,Php,Jquery,Json,Posting,我创建了一个jquery,以了解我输入的商品编号是否有效。如果有效,则会有一个文本说明它有效,用户会键入所述商品的订购数量。之后,它会自动显示商品说明、每单位价格和商品价格*数量的总价 我的问题是。当我声明$unit_price=$\u POST['unitprice']时,如何在填写表单后将其保存到数据库中 它有一个未定义索引的错误。这是我的密码 这是我的剧本 $('#feedback3').load('itemlist.php').show(); $('#stock

我创建了一个jquery,以了解我输入的商品编号是否有效。如果有效,则会有一个文本说明它有效,用户会键入所述商品的订购数量。之后,它会自动显示商品说明、每单位价格和商品价格*数量的总价

我的问题是。当我声明$unit_price=$\u POST['unitprice']时,如何在填写表单后将其保存到数据库中

它有一个未定义索引的错误。这是我的密码

这是我的剧本

        $('#feedback3').load('itemlist.php').show();

    $('#stock_input').keyup(function(){
    $.post('itemlist.php', { stock_number: form.stock_number.value }, 
        function(result) {
            $('#feedback3').html(result.message).show();

            displayTotal(result.price);


    }, 'json');
    });

    $('#quantity').keyup(function(){
    $.post('itemlist.php', { stock_number: form.stock_number.value }, 
        function(result) {
            $('#feedback3').html(result.message).show();
            $('#itemdesc').html(result.desc).show();
            $('#unitprice').html(result.price).show();
            displayTotal(result.price);




    }, 'json');

    }); 
});
这是我的输入类型,但结果是未定义索引

    <tr>
        <td><text class="normal">Item Number: </text></td> 
        <td><input type="text" class="input" name="stock_number" id="stock_input" > <text id="feedback3"></text></td>
    </tr>
    <tr>
        <td><text class="normal">Unit price : </text></td> 
        <td><span>   $ </span><text id='unitprice' name="unit_price"></text></td>
    </tr>
    <tr>
        <td><text class="normal">Description : </text></td> 
        <td><span id='itemdesc' name='desc'></span></td>
    </tr>
    <tr>
        <td><text class="normal">Quantity: </text></td> 
        <td><input type="text" class="input" name="quantity" id="quantity" ><text id="feedback4"></text></td>
    </tr>
    <tr>
        <td><text class="normal">Size : </text></td> 
        <td><input type="text" class="input" name="size"</td>
    </tr>
    <tr>
        <td><text class="normal">Customize Information : </text></td> 
        <td><textarea cols="40" rows="4" name="custom"> </textarea></td>
    </tr>
    <tr>
        <td><text class="normal">Total Price : </text></td> 
        <td> <span>   $ </span><span id='totalPrice' name='total'></span></td>
    </tr>
</table></fieldset><br>

谢谢你

我认为你在使用jquery/ajax时没有$\u POST['submit']。尝试在php文件中输入它

print_r($_POST);die;
看看你得到了什么…

你没有将单价发送到服务器。我建议您阅读以下文件:
print_r($_POST);die;