2

I am sooo stuck on this, cannot figure it out. I am trying to have the user select the date using the date selector in HTML5 and then query the sql database to find the date and output the results in a table below. I have been working on this for literally hours, cannot get past it, please help.

HTML

Date for retrieve: <input type="date" name="pickupDate" value="<?php echo $pickupDate;?>">
<span class="error">
</p>
<p>
Show date item for retrieve: 
<input type="radio" name="input" value="requestDate1">Request Date 
<input type="radio" name="input" value="pickupDate1">Pickup Date
</p>
<p><input type="submit" value="Show"></p>

$requestDate = mysqli_real_escape_string($db, isset($_POST["pickupDate"]));

PHP

if ($_SERVER["REQUEST_METHOD"] == "POST") {

if ($_POST["input"] == "requestDate1") {


    $query = "SELECT requestDate FROM request WHERE requestDate = '$requestDate'";
    echo "working";

2 Answers2

1

I think your problem is with this selection query:

$query = "SELECT requestDate FROM request WHERE requestDate = '$requestDate'";

Please change it in this way:

$query = "SELECT requestDate FROM request WHERE requestDate = '" . $requestDate . "';";

Or if it's not working then check the date format both on frontend and backend, and if it's needed change the date format on backend to match it with frontend.

Endre Simo
  • 11,330
  • 2
  • 40
  • 49
0

This is simple: SQL uses the YMD HIS format to store date in to it's field, and HTML5 uses DDMMYYYY so if you want to use this date format, your required to change the format, I suggest you go through this answer in stackoverflow for more details...

HTML 5 Date format

Community
  • 1
  • 1
Marmik Bhatt
  • 607
  • 4
  • 16