Przemysław Lunic Przemysław Lunic - 1 year ago 77
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 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; ?>">


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

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

Answer Source

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

$ldateFrom = date('Y-m-d', strtotime($_POST['dateFrom']));
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download