Przemysław Lunic Przemysław Lunic - 1 month ago 8
MySQL Question

Multiple input type data on one page

I'm having hard time figuring how I can pass from multiple input forms with date type directly to mysql, when I'm trying to print_r or echo what I have here the date is always 01-01-1970. I saw a similar problem here: stacklink but I'm not sure how he get it working? What am I missing?

<form method="POST" action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>">
<div class="form-group col-lg-offset-2 col-lg-4">
<h3 class="text-center"><strong>Data przybycia:</strong></h3>
<hr />
<input class="form-control" name="dateFrom" value="<?php
echo $dateNextDay; ?>" type="date" min="<?php
echo $dateNextDay; ?>">
</div>

<div class="form-group col-lg-4">
<h3 class="text-center"><strong>Data odjazdu:</strong></h3>
<hr />
<input class="form-control" name="dateTo" value="<?php
echo $dateNextDayNextDay; ?>" type="date" min="<?php
echo $dateNextDayNextDay; ?>">
</div>


PHP:

if($_SERVER["REQUEST_METHOD"] == "POST"){
$ldateFrom = date('Y-m-d', strtotime($POST_['dateFrom']));

$ldateTo = date('Y-m-d', strtotime($POST_['dateFrom']));

Answer

You have to access the $_POST value like this instead of $POST_['dateFrom']

$ldateFrom = date('Y-m-d', strtotime($_POST['dateFrom']));
Comments