Question : checking for empty value

hello
can someone help me with this code i have posted. what i am trying to do is if the post submitted is empty then that becomes the session or if there is a value then set the session with that value. many thanks
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
if(isset($_POST['datepicker'])){
	if ($_POST['datepicker'] == '') {
		$datepicker = $_POST['datepicker'];
		}
		else
		{
		$date_parts = explode("/",$_POST['datepicker']);
		$newDate = $date_parts[2]  . "-" . $date_parts[1] . "-" . $date_parts[0];
		$datepicker = date('Y/m/d', strtotime($newDate));
		
}
}
$_SESSION['datepick'] = $datepicker;

Answer : checking for empty value

For your version you mey try this
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
<?php
$datepicker='';
if(isset($_POST['datepicker']) && trim($_POST['datepicker']) != ''){
	list($d, $m, $y) = explode('/', trim($_POST['datepicker']));
	$mk=mktime(0, 0, 0, $m, $d, $y);	
	$datepicker=getdate($mk);
}
session_start();
$_SESSION['datepick'] = $datepicker;
?>
Random Solutions  
 
programming4us programming4us