i have a php file with this code:
<?php
dateIndaysoff($_GET['date']);
function dateIndaysoff($mydate){
if(!$mydate)return false;
$host = "localhost";
$user = "user";
$pass = "pass";
$databaseName = "db";
$con = new mysqli($host,$user,$pass,$databaseName);
if ($con->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$query = "SELECT date FROM table WHERE date = '$mydate'";
$result = $con->query($query);
if ($result->num_rows < 1) {$exists = "FALSE";} else {$exists = "TRUE";}
return $exists;
}
?>
Now in my .js file i use this
jQuery(".datepicker").change(function() {
var val = jQuery(this).datepicker().val();
var finalval = jQuery.get("url-to-phpfile/daysoff.php",{date:val});
if (finalval) {
but its like i always have true as result. php by its own works perfect. i am trying in jquery to call php and pass through url the value from datepicker and if result is true do something. I have tried the jquery with a fixed value and its working like a charm. The mistake i do should be or inside php receiving the value with GET or in jquery receiving the result.
What do i do wrong?
$_GET['date']? How is it stored in the db?