Forum Moderators: coopster
$datein = date("Y-m-d",strtotime($_POST['date_in']));
$datescrapped = date("Y-m-d",strtotime($_POST['date_scrapped']));
$sql="INSERT INTO scrapped (scrapped_date_in, scrapped_date_scrapped, scrapped_make, scrapped_model, scrapped_registration, scrapped_entered_by, scrapped_last_keeper, scrapped_date_logged) VALUES ('$datein', '$datescrapped', '$_POST[manufacturer_id]', '$_POST[model]', '$_POST[registration]', '$_POST[employee_id]', '$_POST[last_keeper]', CURDATE() )";
$checkresult = mysql_query($sql);
$errors = null;
$datein = date("Y-m-d",strtotime($_POST['date_in']));
$datescrapped = date("Y-m-d",strtotime($_POST['date_scrapped']));
//
if (! preg_match('/^\d{4}\-\d{2}\-\d{2}$/',$datein)) {
$errors .= "<li>The date in, $datein, is in the wrong format.</li>\n";
}
//
if (! preg_match('/^\d{4}\-\d{2}\-\d{2}$/',$datescrapped)) {
$errors .= "<li>The date scrapped, $datescrapped, is in the wrong format.</li>\n";
}
//
if ($errors) {
echo "<ul>$errors</ul>";
exit;
}
<td><input type="text" class="w100" id="date_in" name="date_in" value="" /></td>
<td><input type="text" class="w100" id="date_scrapped" name="date_scrapped" value="" /></td>
if(isset($_POST['submit'])){
$errors = null;
$datein = date("Y-m-d",strtotime($_POST['date_in']));
$datescrapped = date("Y-m-d",strtotime($_POST['date_scrapped']));
//
if (! preg_match('/^\d{4}\-\d{2}\-\d{2}$/',$datein)) {
$errors .= "<li>The date in, $datein, is in the wrong format.</li>\n";
}
//
if (! preg_match('/^\d{4}\-\d{2}\-\d{2}$/',$datescrapped)) {
$errors .= "<li>The date scrapped, $datescrapped, is in the wrong format.</li>\n";
}
//
if ($errors) {
echo "<ul>$errors</ul>";
exit;
}
$sql="INSERT INTO scrapped (scrapped_date_in, scrapped_date_scrapped, scrapped_make, scrapped_model, scrapped_registration, scrapped_entered_by, scrapped_last_keeper, scrapped_date_logged) VALUES ('$datein', '$datescrapped', '$_POST[manufacturer_id]', '$_POST[model]', '$_POST[registration]', '$_POST[employee_id]', '$_POST[last_keeper]', CURDATE() )";
$checkresult = mysql_query($sql);
if ($checkresult) {
header("location:scrapped-insert.php?mode=success");
exit();
}
echo $datein;
echo $datescrapped;
}
<?php
while($row=mysql_fetch_array($result_all)) {
$row_color = ($row_count % 2) ? $color1 : $color2;
?>
<tr>
<td><?=$row['scrapped_date_in']?></td>
<td><?=$row['scrapped_date_scrapped']?></td>
<td><?=$row['scrapped_make']?></td>
</tr>
I don't like the fact it shows 2011-05-10 in the field as I think this will confuse the users
$sql="select date_format(scrapped_date_in, '%d/%m/%Y') as scr_in, date_format(scrapped_date_scrapped, '%d/%m/%Y') as dt_scr, scrapped_make from scrapped";