Jump to content

The Zero in the day and month will not post


phpretard

Recommended Posts

I am trying to compare values and if the month is not of 2 digits then the comparison goes wrong.

 

Here is some hacked crap that doesn't work.


if (strlen($_POST['m'] <= 1)){$month = "0".$_POST['m'];}else{$month = $_POST['m'];}
if (strlen($_POST['d'] <= 1)){$day = "0".$_POST['d'];}else{$day = $_POST['d'];}

<form>

function GetDays(){
    $Listd = '<select name="d">';
if (isset($_POST['d'])){$Listd .='<option value="'.$_POST['d'].'">'.$_POST['d'].'</option>';}
    for ($x = 1; $x <= date('d'); $x++)
$Listd .= '<option value="'.$x.'">'.$x.'</option>';
    $Listd .= '</select>';
    return $Listd;
}

function GetMonths(){
    $Listm = '<select name="m">';
if (isset($_POST['m'])){$Listm .='<option value="'.$_POST['m'].'">'.$_POST['m'].'</option>';}
    for ($x = 1; $x <= date('m'); $x++)
$Listm .= '<option value="'.$x.'">'.$x.'</option>';
    $Listm .= '</select>';
    return $Listm;
}

 

Here is what I am comparing:

Now:          201012141292327875

Submitted: 201110101292353200 // 2 digit month/day

 

Now:          201012141292327984

Submitted: 2011991292353200 // not 2 digits month/day

 

2 hours is enough for me...can someone shed some light on this for me please?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.