Newbie help - form validation of a number
Posted: Thu Jan 15, 2009 1:41 pm
I need to create a really simple page where we validate a number entered by a user. They enter their library card number if it is 13 characters long and starts with "10001" then they get directed to a web page, if not they get dumped back to the data entry page with a message that they need to enter a valid library card number. We don't need to check that it is actually a real library card number - just that it is 13 characters and starts with "10001" So this seems pretty simple, but I am very, very new to PHP and I would love some help.
I think I need to use the strlen function to check that it is 13 characters so something like "$libIDLength = strlen($libID)" Then I could say if $libIDLength == 13 redirect, if not error.
I am not sure how to get the first 5 characters and check to see if they are "10001" though.
I am also not sure how to do a two condition If statement. The data needs to be both 13 character and start with "10001" but all the If/else examples I have seen just have one condition for each else.
Can someone help me sort this out a bit?
Thank you so much for any help
I think I need to use the strlen function to check that it is 13 characters so something like "$libIDLength = strlen($libID)" Then I could say if $libIDLength == 13 redirect, if not error.
I am not sure how to get the first 5 characters and check to see if they are "10001" though.
I am also not sure how to do a two condition If statement. The data needs to be both 13 character and start with "10001" but all the If/else examples I have seen just have one condition for each else.
Can someone help me sort this out a bit?
Thank you so much for any help