I am trying to create the form to add data into the SQL database. It fetches first the data for me that already exist in the other table and then I them to be added into database along with form i have created. But despite no errors the data is not inserted it comes back with 0 ROWS. I tried to fix it for hours and i can't think of anything that would fix it.
Here is my code that fetches the data from existing table:
<form action="" method = "POST" class="form-horizontal">
<fieldset>
<legend>Action Taker:</legend>
<label class="control-label col-lg-4">Employee Name: </label>
<input type="text" name="employ_first" value ="<?php echo (isset($row['first_name'])&&!empty($row['first_name'])) ? $row['first_name'] : ''; ?>" disabled>
<input type="text" name="employ_second" value ="<?php echo (isset($row['second_name'])&&!empty($row['second_name'])) ? $row['second_name'] : ''; ?>" disabled>
<label class="control-label col-lg-4">Staff Comment: </label>
<input type="text" name="reason_emp" value ="<?php echo (isset($row['reason'])&&!empty($row['reason'])) ? $row['reason'] : ''; ?>" size="100" disabled>
<div>
</div>
<div>
<label class="control-label col-lg-4">Add Respond Comment:</label>
<div class="col-lg-4">
<input type="text" name="admin_respond" class="form-control" size="50px"/>
</div>
<div>
</div>
</div>
<input type="submit" name="submit" class="form-control" value="Add" />
</form>
Here is the FORM code:
<form action="meeting_schema.php" method = "POST" class="form-horizontal">
<h3>Fill The Form For Investigation:</h3>
<div>
<label>Type of Investigation:</label>
<input name="type" type="text">
<label>Set Date:</label>
<input name="set_on_date" type="date">
<label>Set Time:</label>
<input name="set_on_time" type="time">
<label>Assigned to:</label>
<input name="assigned_to" type="text">
<input type="submit" name="add_meeting" value="Create Meeting" />
</div>
</form>
And here is my action php file meeting_schema:
<?php
$hostnames = "localhost";
$usernames = "u3253997...";
$passwords = "Ws.....";
$databaseNames = "u3253997...";
$conns= mysqli_connect($hostnames, $usernames, $passwords, $databaseNames);
if (!$conns) {
die('Connection failed: ' . mysqli_connect_error());
}
if (!$conns) {
die("Connection failed: " . mysqli_connect_error());
}
if(isset($_POST['add_meeting'])){
$stmt = $conns->prepare("INSERT INTO `emp_inv` (`meeting.id`,`employ_first`,`employ_second`,`reason`,`type`,`set_on_date`, `set_on_time`, `set_by`, `assigned_to`) VALUES (NULL,?,?,?,?,?,?,?,?)");
if (!$stmt) {
echo "There is an error in the source code, please contact support to fix the problem.";
}
else {
$stmt->bind_param('ssssssss', $_POST['employ_first'], $_POST['employ_second'], $_POST['reason_emp'], $_POST['type'], $_POST['set_on_date'], $_POST['set_on_time'], $_SESSION['set_by'], $_POST['assigned_to']);
$stmt->execute();
echo "Meeting has been created";
header("location:meetings.php");
}
}
?>