<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進行連接。 –