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/ ?php // Get this from where ever (format MM-DD-) echo

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 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 unsubscribe,

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 perhaps? you

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

2008-01-15 Thread Adam Williams
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 unsubscribe, visit: http://www.php.net/unsub.php

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/)

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 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,

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 the data,

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, rather than

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 easier to

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,

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. /Per

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 ago about the

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/) To

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 a

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 date);

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 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)) { die (you have

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.

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 display

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 display

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 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_DATE

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

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_DATE

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

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

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 instead of

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 insert

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 fields. All I