<form name="screenDishForm" action="bentoQuery.php" method="POST">
<!--Label and input for the name of dish -->
<label class="contentLabel"> Name: </label><br>
<input class="inputField" type="text" id="dishName" name="dishName" placeholder="E.g. Beef Teriyaki" required><br>
<!-- Label and Drop down list for the type of dish -->
<label class="contentLabel"> Type: </label><br>
<select class = "inputField" id="dishType" name = "dishType">
<option value="mainDish">Main Dish</option>
<option value="sideDish">Side Dish</option>
<option value="soup">Soup</option>
</select><br>
<!--Label and input for the price of dishes -->
<label class="contentLabel"> Price: </label> <br>
<input class="inputField" type="number" minimum="0" id="dishPrice" name="dishPrice" required><br>
<!--Button that will be used to register the dishes. -->
<button class="btnRegister" type="submit" name="submit"> Register Dish </button>
</form>
这是我的形式,我命名为bentoApp.php如何从表格中获取数据
<?php
require_once 'dbConn.php';
$dishName = $_POST['dishName'];
$dishType = $_POST['dishType'];
$dishPrice = $_POST['dishPrice'];
$sql = "INSERT INTO dish(dishName, dishType, dishPrice)
VALUES ('$this->dishName', '$this->dishType', '$this->dishPrice')";
?>
这是我BentoQuerry.php内容
我怎么获取数据的形式? 原来的错误
Fatal error: Using $this when not in object context in
那么,所有这些在哪里?如果你没有使用类,那你为什么使用'$ this->'而不是变量?您也从未执行过查询,也无法知道您使用哪个API进行连接。 –