Re: Comparing birth date with the code
| From: | Steve Edberg | Date: | Wed, 30 Aug 2000 23:00:52 +0000 |
| Subject: | Re: Comparing birth date with the code | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-14478@lists.php.net to get a copy of this message | ||
At 6:26 PM +0200 8/30/00, Siim Einfeldt wrote:
I have form <FORM METHOD=POST ACTION="check.php3"> Your birthday (YY-MM-DD):<INPUT TYPE="text" NAME="birthday"><BR> Personal code:<INPUT TYPE="text" NAME="code" maxlength="11"><BR> </FORM> the 'code' has length of 11 digits (38202124400 for example) birthday for example can be 82-02-12. How can I check if the birthday numbers match with numbers from the 'code' field (from the second character from left to the fifth character from right, eg[820212])? Thank you in advance, Siim Einfeldtif (substr($code, 1, 6) == str_replace('-', '', $birthday)) { # Match!!! } For more info on these functions, see http://www.php.net/manual/function.substr.php and http://www.php.net/manual/function.str-replace.php Keep in mind that this won't work if someone enters a single-digit date, eg '82-1-30'. You'll have to do a little more work to take that into account, or turn the birthday entry part of the form into a series of <SELECT>...</SELECT> drop-downs. -steve +--- "They've got a cherry pie there, that'll kill ya" ------------------+
| Steve Edberg University of California, Davis | | sbedberg@ucdavis.edu Computer Consultant | | http://aesric.ucdavis.edu/ http://pgfsun.ucdavis.edu/ |+-------------------------------------- FBI Special Agent Dale Cooper ---+