Hi, so im trying to insert data but i get:
Notice: Undefined index: events
html part:
<form method="post" action="seating.php>
<div class="drop">
<label>Event : <label/>
<select name="events" id="dd-events" onchange="getguests(this.value)">
<option value="" disabled selected >Event</option>
<?php foreach($retrieve as $r): ?>
<option value="<?=$r['event_id']?>"><?=$r['event_name']?></option>
<?php endforeach ?>
</select>
</div>
<input type="hidden" name="table_name[]" value='+tablename+'><span class="tableName">'+tablename+'</span>
<input type="text" name="guestname[]" class="add-name" size="40">
</form>
php:
<?php
if(isset($_SESSION['sess_user_id']))
{
if(isset($_POST['save-seating']))
{
require "connection.php";
$name = $_POST['guestname'];
$table = $_POST['table_name'];
$event = $_POST['events'];//<- THIS LINE
$sess = $_SESSION['sess_user_id'];
$seats = $dbh->prepare("INSERT INTO tables(tuser_id,table_name,event_id,guest_name)
VALUES(?,?,?,?)");
for($i = 0; $i < count($_POST['guestname']); $i++)
{
if(trim($_POST['guestname'][$i]) != '')
{
$seats->bindParam(1, $sess);
$seats->bindParam(2, $table[$i]);
$seats->bindParam(3, $event);
$seats->bindParam(4, $name[$i]);
if(!$seats->execute())
{
echo "fail!";
}
}
}
}
}
?>
Im still a baby at php and all programming so I can't see where I made a mistake. could someone point it out to me please. thank you.