PDA

View Full Version : Form Redirect--based on zip code



timhersh
16 Apr 2010, 09:15 PM
need help with this one, I am designing a website for an insurance company who has 4 locations. They have a link called Easy Quote, on this page it has a text box for zip code, when the user enters the zip code they should be sent to the quote page...BUT it needs to go to a certain quote page depending on their zip code.

I can take care of most of this but am not sure how to write a script that will read the zip code then compare it to my list, or maybe a IF statement, then based on that zip code it sends it to a certain page, otherwise it sends it to a different page.

Please help

one other thing, we would like to alternate which page it goes to for one zip code. For example if someone enters 12456 it would send them to form1.php first, then the next time someone enters that it would send them to form2.php, then the next time back to form1.php

any ideas

thanks

Trillium
23 Apr 2010, 08:29 AM
I don't know exactly how zip codes work (we Canadians use Postal Codes :)), but I'm assuming that there is some sort of way that you can determine which of the four regions your code is from. That being the case, you could develop 4 regular expressions (each matching one of the regions) and then you could run some code that determines which region the entered zip code matches, and then all you have to do is send them to the appropriate page.

As to the alternating page thing, you will probably already have a database of customer information right? So you can simply store (in that same database) a piece of information that tells you how many times that customer has accessed the form. Then whenever a customer goes to access the form, you see if the customer has already registered, and if he has, then get the number of times he has viewed the form, then show the form and increment the "view_times" (or whatever you call it) data. The way that you use that data to determine which form to show would be like so:


if($view_times % 2 == 0){
show_form1();
}
else{
show_form2();
}