0
$date =date("m-d-Y");  
    $selected =$_REQUEST['sel_day'];// Selected date

$today = strtotime($date); $expiration_date = strtotime($selected); 
    if ($expiration_date > $today) { 
    echo $valid = "yes"; } else { echo $valid = "no"; }

not working?
please help

Edited by happygeek: fixed formatting

3
Contributors
8
Replies
9
Views
5 Years
Discussion Span
Last Post by almostbob
0

use [code=language]code [/code] tags, helps
the echo statements are wrong, setting a variable does not need to be echoed, echoing an answer does not need a variable name

$date =date("m-d-Y"); 
$selected =$_REQUEST['sel_day'];// Selected date
$today = strtotime($date); $expiration_date = strtotime($selected); 
if ($expiration_date > $today) { 
echo $valid = "yes"; } else { echo $valid = "no"; }

perhaps something like

(strtotime($_REQUEST['sel_day']) > date() ? $valid = "yes" : $valid = "no");

if else ternary operator ( condition ? result if true : result if false );
default: date() = today text strings are messy and unneccessary

Edited by almostbob: n/a

0

use [code=language]code [/code] tags, helps
the echo statements are wrong, setting a variable does not need to be echoed, echoing an answer does not need a variable name

$date =date("m-d-Y"); 
$selected =$_REQUEST['sel_day'];// Selected date
$today = strtotime($date); $expiration_date = strtotime($selected); 
if ($expiration_date > $today) { 
echo $valid = "yes"; } else { echo $valid = "no"; }

perhaps something like

(strtotime($_REQUEST['sel_day']) > date() ? $valid = "yes" : $valid = "no");

if else ternary operator ( condition ? result if true : result if false );
default: date() = today text strings are messy and unneccessary

Not working

if ((strtotime($_REQUEST['sel_day']) > date() ? $valid = "yes" : $valid = "no") ) 
	echo $valid;
0

THere is no IF() statement in my code
the single line ternary statement replaces entirely, all of,

If(condition) {action}
else {action}

try

(strtotime($_REQUEST['sel_day']) > date() ? $valid = "yes" : $valid = "no");
echo $valid;

You have validated the submission elsewhere in the code?? 'sel_day' does exist.

Edited by almostbob: n/a

1
$valid = (strtotime($_REQUEST['sel_day']) > time()) ? "yes" : "no";
echo $valid;

date() need a format parameter, so it probably won't work.

Edited by diafol: n/a

0
$valid = (strtotime($_REQUEST['sel_day']) > time()) ? "yes" : "no";
echo $valid;

date() need a format parameter, so it probably won't work.

@ardav

Thanks for your help...it works.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.