Bill Cosby is my Father
Gender:
Posts: 4
28 credits Members referred : 0
Try try again !
« on: Jul 29, 2007, 02:54:05 AM »
Olaf, please review this. I wanted a scipt to check the validity of the post code entered.(So only valid codes fill my database). I wanted to give a little back to help someone else save the time I spent. Cheers!
This is what I came up with. I added this to the ext_user_profile.php
The tables used can be downloaded @ http://www.sanisoft.com/phpziplocator.
Here is the simple code I added. Appears to work fine so far, but please review.
I added this to the extra_text: $extra_msg[4] = "Postcode is invalid! Try again.";
Moderator Community Supporter?
Jedai Sword Master
Gender:
Posts: 6309
38674 credits Members referred : 374
It's time to use PHP5!
« Reply #1 on: Jul 29, 2007, 11:16:24 AM »
hmm... nice, I know that the US zip code is 100% numeric, testing the value against a database is possible but is a test against a regular expression not faster (enough)?
Bill Cosby is my Father
Gender:
Posts: 4
28 credits Members referred : 0
Try try again !
« Reply #2 on: Jul 29, 2007, 09:42:15 PM »
I think what your saying is use the regular expressions to check for the correct snytax of the postcode entered, when what I had in mind(which probably takes longer); is to check the submitted value against a complete listing of all postal codes.
I want to ensure when a search is done later that all results are valid. Is this over kill and if so, can you reccommend a better method.
Cheers!
Moderator Community Supporter?
Jedai Sword Master
Gender:
Posts: 6309
38674 credits Members referred : 374
It's time to use PHP5!
« Reply #3 on: Jul 29, 2007, 11:08:04 PM »
but how do you protect your application about cheating entries? do you have second validation that the entered value belongs to the user?
Bill Cosby is my Father
Gender:
Posts: 4
28 credits Members referred : 0
Try try again !
« Reply #4 on: Jul 29, 2007, 11:15:37 PM »
Fair enough, I was pretty tired last night and did not think of that immediately. I will add the testing with the regular expressions before it is checked against the database for validity.
Moderator Community Supporter?
Jedai Sword Master
Gender:
Posts: 6309
38674 credits Members referred : 374
Fair enough, I was pretty tired last night and did not think of that immediately. I will add the testing with the regular expressions before it is checked against the database for validity.
that will not help
if you need to be 100% sure you need to match the postal code against the address/city
Bill Cosby is my Father
Gender:
Posts: 4
28 credits Members referred : 0
Try try again !
« Reply #6 on: Jul 30, 2007, 01:31:07 AM »
I think I understand . So take the postcode, and check against the address & city sumitted. This may be more than what I need, but you answered my question on how make 100% sure it's valid.
Thanks !
Moderator Community Supporter?
Jedai Sword Master
Gender:
Posts: 6309
38674 credits Members referred : 374
I think I understand . So take the postcode, and check against the address & city sumitted. This may be more than what I need, but you answered my question on how make 100% sure it's valid.
Thanks !
you're welcome, be sure that you only validate the data you really need. It makes no sense to validate the address from someone who has the chance to win $1mio if he enter his address