Here is my code, if I check PHP error log there are no errors, as far as I can tell the database is connected to and the data is being processed however it is not showing up in the DB table 'calendar'?
here is config.php:
<?php
global $db;
global $productid;
$db = mysqli_connect("localhost", "********", "********", "database");
if (mysqli_connect_errno($db)) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
// checks if user is logged in for admin panel
function isLoggedin ($db)
{
if (isset($_SESSION['login'])) {
$query = mysqli_query($db, "SELECT ID, username FROM sr_users WHERE ID='".mysqli_real_escape_string($db, $_SESSION['login_userId'])."'") or die(mysql_error());
$row = mysqli_fetch_array($query, MYSQLI_ASSOC);
if ($_SESSION['login_hash'] == hash('sha512', $row['username'] . $row['ID'])) {
return true;
} else {
session_destroy();
header("location: login.html");
}
} else {
session_destroy();
header("location: login.html");
}
}
if (isset($_GET['productid'])) {
if (!empty($_GET['productid'])) {
$productid = $_GET['productid'];
} else {
$productid = '';
}
} else {
$productid = '';
}
?>
Here is date picker (using jquery-ui) to insert date into calendar db:
<?php
session_start();
include_once("./config.php");
isLoggedin ($db);
?>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery UI Datepicker - Default functionality</title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
<script>
$(function() {
$( "#datepicker" ).datepicker({dateFormat: 'yy-mm-dd' });
});
</script>
</head>
<body>
<?php
$form = "
<form action='' method='post' id='RegisterForm' autocomplete='off'>
<table>
<tr>
<td><p>Date: <input type='text' name='datepicker' id='datepicker'></p></td>
</tr>
<tr>
<td><input type='submit' name='submitbtn' value='Register'></td>
</tr>
</table>
</form>
";
if ($_POST['submitbtn'])
{
$datepicker = strip_tags($_POST['datepicker']);
if ($datepicker)
{
mysqli_query($db, "INSERT INTO calendar (date)
VALUES ('$datepicker')");
echo "<h2>Done!!!</h2>";
}
else
echo "Please enter a valid date";
}
else
echo "$form";
?>
</body>
</html>
I am using the database user from my star reviews (http://codecanyon.net/item/starreviews-ajax-jquery-rating-and-review-form/6584956) adddon, and I have added an extra table for an events calendar (http://www.phpjabbers.com/free-availability-calendar-script/) called 'calendar' and I need to insert the data in? Any ideas?