QA.TechInterviews.com - your tech questions answered
Question For Web Developers.......?
I want my web site visitors to enter their Zip Code and then based on the zip code entered, the website will auto-direct to a page designed specifically for that zip. How do I accomplish this? Mysql? PHP? or is there another way?

Hope somebody can help!
there are a lot of ways to do that... but the easiest probably is by using javascript... redirection is quite simple in javascript:

Ex.:
<script language="javascript">
window.location.href = "www.yahoo.com";
</script>

It would be very handy to create a dropdown list instead of letting your visitors type-in their zip codes because this would prevent them from entering invalid zip codes.

<select onchange="redirectTo(this)">
<option value = "www.yahoo.com">034</option >
<option value = "www.google.com">035</option >
...
</select>

Then add this on the head of your HTML:

<script language="javascript">
function redirectTo(x){
window.location.href=x.value;
}
</script>
the javascript is by far gonna be your best bet! I vote his answer the best due to it's simplicity (especially if u dont know PHP)
Many ways to do this, but your server needs to capture the zip code submission and decide what to do. You can use Perl, Ruby, PHP, whatever your little heart desires, so long as it's supported on your web server. Search the internet for the "input" tag.
there are a lot of ways to do that... but the easiest probably is by using javascript... redirection is quite simple in javascript:

Ex.:
<script language="javascript">
window.location.href = "www.yahoo.com";
</script>

It would be very handy to create a dropdown list instead of letting your visitors type-in their zip codes because this would prevent them from entering invalid zip codes.

<select onchange="redirectTo(this)">
<option value = "www.yahoo.com">034</option >
<option value = "www.google.com">035</option >
...
</select>

Then add this on the head of your HTML:

<script language="javascript">
function redirectTo(x){
window.location.href=x.value;
}
</script>
u can use mysql as your database... and also php... its in you on how you could design the codes in your page... try reading o'reilly LAMP...
If you don't already know the answer to this you'll spend forever figuring it out ... ask someone for help "Faster!"

Back to QA. TechInterviews.com. Powered by Yahoo! Answers and TechInterviews.com community.