First time on here so sorry if I get the formatting wrong!
I have a createperform.php file which has a form that links back to itself. The performancedate and performancetime is posted along with the prod for productionID. I have a database Table called Performance, which has 4 columns (PerformanceID(Auto Inc, int), ProductionID(int), performancedate(date) & performancetime(time))
<form action="createperform.php" method="POST" role="form">
<input type="date" required="required" name="performancedate" id="performancedate" />
<input type="time" required="required" name="performancetime" id="performancetime" />
<select name="prod">
<?php
while($row = $results->fetch_assoc())
{
echo '<option value="' . $row['productionID'] . '">' . $row['productionname'] . '</option>';
}
?>
</select>
<br><br>
<button type="submit" value="Submit" name="submitPerform" class="btn btn-default">Create Performance</button>
</form>
Here is my PHP at the top of the createperform.php:
<?php
session_start();
include("includes/adminheader.php");
include("db.php");
$results = $conn->query("SELECT * FROM Production");
if (isset($_POST["submitPerform"]))
{
$performancedate = mysqli_real_escape_string($conn, $_POST["performancedate"]);
$performancetime = mysqli_real_escape_string($conn, $_POST["performancetime"]).":00";
$prodID = mysqli_real_escape_string($conn, $_POST["prod"]);
$aresult = $conn->query("INSERT INTO Performance (productionID, performancedate, performancetime,)
VALUES('{$prodID}','2015-06-23','02:34:24')");
if ($aresult)
{
$message = "Performance successfully added to Production ID: ".$prodID;
}
else
{
$message = "Performance failed to get added to Production ID: ".$prodID;
}
}
?>
The db connection is in db.php, I keep getting the else part of the if($aresult) state that executes. I have checked my table names, check my variable names, I am getting no errors at all. I made sure that the format of the date is: YYYY-MM-DD and made sure that the format or the time is HH:MM:SS.
I printed out the values stored in the date and time variables and this is what I got:
<br><h3><?php echo $message; echo $performancedate; echo $performancetime;?></h3><br>
Performance failed to get added to Production ID: 52015-03-2923:54:00
I have ran out of things that I can try now. If you need anything else let me know.