Re: [PHP] checking user input of MM-DD-YYYY

2008-01-15 Thread Andrew Ballard
On Jan 15, 2008 2:38 PM, Richard Lynch <[EMAIL PROTECTED]> wrote: > On Tue, January 15, 2008 12:31 pm, Adam Williams wrote: > > Andrew Ballard wrote: > > I don't see the point in needing to convert it to a timestamp. The > > length_start and length_end fields in MySQL are defined as date > > field

Re: [PHP] checking user input of MM-DD-YYYY

2008-01-15 Thread Richard Lynch
On Tue, January 15, 2008 12:31 pm, Adam Williams wrote: > Andrew Ballard wrote: > I don't see the point in needing to convert it to a timestamp. The > length_start and length_end fields in MySQL are defined as date > fields. > All I care about is the date, not the hours/minutes/seconds. If I > in

Re: [PHP] checking user input of MM-DD-YYYY

2008-01-15 Thread Nathan Nobbe
On Jan 15, 2008 2:24 PM, Andrew Ballard <[EMAIL PROTECTED]> wrote: > On Jan 15, 2008 2:05 PM, Brady Mitchell <[EMAIL PROTECTED]> wrote: > > > I'm having users enter dates in MM-DD- format. is there a way > > > to check if what they have entered is invalid (like if they enter > > > 1-15-2008 i

Re: [PHP] checking user input of MM-DD-YYYY

2008-01-15 Thread Andrew Ballard
On Jan 15, 2008 2:05 PM, Brady Mitchell <[EMAIL PROTECTED]> wrote: > > I'm having users enter dates in MM-DD- format. is there a way > > to check if what they have entered is invalid (like if they enter > > 1-15-2008 instead of 01-15-2008) ? > > Why not use something like http://www.dynarch.co

Re: [PHP] checking user input of MM-DD-YYYY

2008-01-15 Thread Adam Williams
Andrew Ballard wrote: All the more reason I would turn it into a timestamp or DateTime object in PHP first. That will prevent trying to insert something like what I used above. Then I would get rid of the MySQL STR_TO_DATE function in the $mysqli_insert_sql value just replace it with something li

Re: [PHP] checking user input of MM-DD-YYYY

2008-01-15 Thread Andrew Ballard
On Jan 15, 2008 1:31 PM, Adam Williams <[EMAIL PROTECTED]> wrote: > Andrew Ballard wrote: > > All the more reason I would turn it into a timestamp or DateTime > > object in PHP first. That will prevent trying to insert something like > > what I used above. Then I would get rid of the MySQL STR_TO_D

Re: [PHP] checking user input of MM-DD-YYYY

2008-01-15 Thread Brady Mitchell
I'm having users enter dates in MM-DD- format. is there a way to check if what they have entered is invalid (like if they enter 1-15-2008 instead of 01-15-2008) ? Why not use something like http://www.dynarch.com/projects/calendar/ to make it easier for the users? Along with being easi

Re: [PHP] checking user input of MM-DD-YYYY

2008-01-15 Thread Nathan Nobbe
On Jan 15, 2008 1:31 PM, Adam Williams <[EMAIL PROTECTED]> wrote: > Andrew Ballard wrote: > > All the more reason I would turn it into a timestamp or DateTime > > object in PHP first. That will prevent trying to insert something like > > what I used above. Then I would get rid of the MySQL STR_TO_

Re: [PHP] checking user input of MM-DD-YYYY

2008-01-15 Thread Jim Lucas
Adam Williams wrote: I'm having users enter dates in MM-DD- format. is there a way to check if what they have entered is invalid (like if they enter 1-15-2008 instead of 01-15-2008) ? $utime = strtotime($_POST['input']); if ( $utime !== false && $_POST['input'] == date('m-d-Y',

Re: [PHP] checking user input of MM-DD-YYYY

2008-01-15 Thread Andrew Ballard
On Jan 15, 2008 11:51 AM, Adam Williams <[EMAIL PROTECTED]> wrote: > > > Andrew Ballard wrote: > > Just curious why you won't take 1-15-2008. Once you validate it, you > > can always assign it to a variable as either a timestamp or a DateTime > > object and then format it however you want when you

Re: [PHP] checking user input of MM-DD-YYYY

2008-01-15 Thread Daniel Brown
On Jan 15, 2008 11:51 AM, Adam Williams <[EMAIL PROTECTED]> wrote: > > > Andrew Ballard wrote: > > Just curious why you won't take 1-15-2008. Once you validate it, you > > can always assign it to a variable as either a timestamp or a DateTime > > object and then format it however you want when you

Re: [PHP] checking user input of MM-DD-YYYY

2008-01-15 Thread Adam Williams
Andrew Ballard wrote: Just curious why you won't take 1-15-2008. Once you validate it, you can always assign it to a variable as either a timestamp or a DateTime object and then format it however you want when you display it, send it to a database, or whatever you are doing with the date. FWIW

Re: [PHP] checking user input of MM-DD-YYYY

2008-01-15 Thread Per Jessen
Adam Williams wrote: > Thanks, I think I have it: > > $dateexplode = explode("-", $_POST["date_entered"]); > if (!preg_match("/^(\d{2})$/", $dateexplode[0],$data1) || > !preg_match("/^(\d{2})$/", $dateexplode[1],$data2) || > !preg_match("/^(\d{4})$/", $dateexplode[2],$data3)) > { >

Re: [PHP] checking user input of MM-DD-YYYY

2008-01-15 Thread Andrew Ballard
On Jan 15, 2008 11:25 AM, Adam Williams <[EMAIL PROTECTED]> wrote: > Thanks, I think I have it: > > $dateexplode = explode("-", $_POST["date_entered"]); > if (!preg_match("/^(\d{2})$/", $dateexplode[0],$data1) || > !preg_match("/^(\d{2})$/", $dateexplode[1],$data2) || > !preg_match("/^(\d{4})$/", $

Re: [PHP] checking user input of MM-DD-YYYY

2008-01-15 Thread Adam Williams
Thanks, I think I have it: $dateexplode = explode("-", $_POST["date_entered"]); if (!preg_match("/^(\d{2})$/", $dateexplode[0],$data1) || !preg_match("/^(\d{2})$/", $dateexplode[1],$data2) || !preg_match("/^(\d{4})$/", $dateexplode[2],$data3)) { die ("you have entered an invalid dat

Re: [PHP] checking user input of MM-DD-YYYY

2008-01-15 Thread Per Jessen
Daniel Brown wrote: > By only doing JavaScript validation, Just in case - I wasn't suggesting only doing javascript validation. I think I said a simple javascript validation _followed_ (as in at POST-time) by a semantic check. For which checkdate() seems pretty optimal. /Per Jessen, Züri

Re: [PHP] checking user input of MM-DD-YYYY

2008-01-15 Thread Per Jessen
clive wrote: > Adam Williams wrote: >> I'm having users enter dates in MM-DD- format. is there a way to >> check if what they have entered is invalid (like if they enter >> 1-15-2008 instead of 01-15-2008) ? >> > explode() and checkdate() perhaps? checkdate() sounds like just the thing. /

Re: [PHP] checking user input of MM-DD-YYYY

2008-01-15 Thread Nathan Nobbe
On Jan 15, 2008 10:46 AM, Daniel Brown <[EMAIL PROTECTED]> wrote: > On Jan 15, 2008 10:38 AM, Richard Lynch <[EMAIL PROTECTED]> wrote: > > > > > > On Tue, January 15, 2008 9:02 am, Per Jessen wrote: > > > Nathan Nobbe wrote: > > > > > >> i think this ties into the thread tedd started a week or so

Re: [PHP] checking user input of MM-DD-YYYY

2008-01-15 Thread Eric Butera
On Jan 15, 2008 9:27 AM, Adam Williams <[EMAIL PROTECTED]> wrote: > I'm having users enter dates in MM-DD- format. is there a way to > check if what they have entered is invalid (like if they enter 1-15-2008 > instead of 01-15-2008) ? > > -- > PHP General Mailing List (http://www.php.net/) >

Re: [PHP] checking user input of MM-DD-YYYY

2008-01-15 Thread Daniel Brown
On Jan 15, 2008 10:38 AM, Richard Lynch <[EMAIL PROTECTED]> wrote: > > > On Tue, January 15, 2008 9:02 am, Per Jessen wrote: > > Nathan Nobbe wrote: > > > >> i think this ties into the thread tedd started a week or so ago > >> about the best approach for collecting user data. > >> it would be much

Re: [PHP] checking user input of MM-DD-YYYY

2008-01-15 Thread Richard Lynch
On Tue, January 15, 2008 9:02 am, Per Jessen wrote: > Nathan Nobbe wrote: > >> i think this ties into the thread tedd started a week or so ago >> about the best approach for collecting user data. >> it would be much easier to validate if there were 3 text input >> fields >> to collect the data, r

Re: [PHP] checking user input of MM-DD-YYYY

2008-01-15 Thread Richard Lynch
On Tue, January 15, 2008 8:27 am, Adam Williams wrote: > I'm having users enter dates in MM-DD- format. is there a way to > check if what they have entered is invalid (like if they enter > 1-15-2008 > instead of 01-15-2008) ? Making the user type the 0 is just plain rude. :-) You could use

Re: [PHP] checking user input of MM-DD-YYYY

2008-01-15 Thread clive
Adam Williams wrote: I'm having users enter dates in MM-DD- format. is there a way to check if what they have entered is invalid (like if they enter 1-15-2008 instead of 01-15-2008) ? explode() and checkdate() perhaps? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, vi

Re: [PHP] checking user input of MM-DD-YYYY

2008-01-15 Thread Nathan Nobbe
On Jan 15, 2008 10:02 AM, Per Jessen <[EMAIL PROTECTED]> wrote: > Nathan Nobbe wrote: > > > i think this ties into the thread tedd started a week or so ago > > about the best approach for collecting user data. > > it would be much easier to validate if there were 3 text input fields > > to collect

Re: [PHP] checking user input of MM-DD-YYYY

2008-01-15 Thread Per Jessen
Nathan Nobbe wrote: > i think this ties into the thread tedd started a week or so ago > about the best approach for collecting user data. > it would be much easier to validate if there were 3 text input fields > to collect the data, rather than 1, free-form field. I would stick to one date field

Re: [PHP] checking user input of MM-DD-YYYY

2008-01-15 Thread Nathan Nobbe
i think this ties into the thread tedd started a week or so ago about the best approach for collecting user data. it would be much easier to validate if there were 3 text input fields to collect the data, rather than 1, free-form field. -nathan

Re: [PHP] checking user input of MM-DD-YYYY

2008-01-15 Thread Richard Heyes
I'm having users enter dates in MM-DD- format. is there a way to check if what they have entered is invalid (like if they enter 1-15-2008 instead of 01-15-2008) ? Something like this: http://www.phpguru.org/date_preg/ '; $result = preg_match('/(\d{2})-(\d{2})-(\d{4})/', $input, $mat

Re: [PHP] checking user input of MM-DD-YYYY

2008-01-15 Thread Tom Chubb
On 15/01/2008, Adam Williams <[EMAIL PROTECTED]> wrote: > > I'm having users enter dates in MM-DD- format. is there a way to > check if what they have entered is invalid (like if they enter 1-15-2008 > instead of 01-15-2008) ? > > -- > PHP General Mailing List (http://www.php.net/) > To unsubs

Re: [PHP] checking user input of MM-DD-YYYY

2008-01-15 Thread Nathan Nobbe
On Jan 15, 2008 9:30 AM, Per Jessen <[EMAIL PROTECTED]> wrote: > Adam Williams wrote: > > > I'm having users enter dates in MM-DD- format. is there a way to > > check if what they have entered is invalid (like if they enter > > 1-15-2008 instead of 01-15-2008) ? > > A regular expression perha

Re: [PHP] checking user input of MM-DD-YYYY

2008-01-15 Thread Per Jessen
Adam Williams wrote: > I'm having users enter dates in MM-DD- format. is there a way to > check if what they have entered is invalid (like if they enter > 1-15-2008 instead of 01-15-2008) ? A regular expression perhaps? /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/)