Hi, I have problem with inserting stalls into my database, i have a foodCourtID which is from another table as a foreign key and i have problems inserting data into my database. Can anyone please take a look and help out? Thanks!
This is my createStalls.php // basically this is the html.
<h2>Stalls</h2>
<hr>
<p></p>
</div>
<form action="adminHandleStalls.php" method="post" enctype="multipart/form-data">
<table>
<tr>
<td>Stall Name</td>
<td>: <input type="text" name="stallName" /></td>
</tr>
<tr>
<td>Stall Image</td>
<td>: <input type="file" name="stallImage"></td>
</tr>
<tr>
<td> </td>
<td align="right"><input type="submit" name="submit" value="Set New FoodCourt"/></td>
</tr>
</table>
</form>
<?php
require_once('../footer.php');
and this is my handleStalls.php // to handle the store
<?php
require_once('../databaseStorage/dbFunction.php');
require_once('/adminHandleFoodCourt.php');
if(empty($stallName) && empty($stallImage)){
echo "Error!";
header("Location: ../admin/adminCreateStalls.php");
}else{
$sqlStr = $db->prepare("INSERT INTO stalls (stallName, stallImage, foodCourtID) VALUES (?,?,?)");
$sqlStr->execute([$_POST['stallName'], $_POST['stallImage'], $_SESSION['foodCourtID']]);
header("Location: ../index.php");
}
Thanks a loads!