<?php
require 'connect.inc.php';
$food= $_POST['food'];
$cost= $_POST['cost'];
$sqlinsert = "INSERT INTO test (eat, pay) VALUES ('$food','$cost')";
?>
<form method = "POST" action = "index.php">
Food: <input type = "text" name = "food">
<br/>
Cost: <input type = "text" name = "cost">
<br/>
<input type = "submit" value = "order">
</form>
为什么我的代码不工作? index.php是好的,它连接好,但没有输出显示在我的数据库中时,我运行此代码。为什么我的代码不能将数据插入数据库?
你在哪里运行查询? – Federkun
由于将查询文本分配给变量并不意味着该查询将被执行。 –
执行mysqli_query() –