"Eric Linders" <elinders88@hotmail.com> wrote in message
news:491326e5.0312290010.78cb148@posting.google.co m...[color=blue]
> Hi everyone. :-)
>
> Our site gets a ton of traffic on our contact forms, which collect the
> standard information (name, address, city, state, zip, home phone,
> etc.) The form validation is done with PHP.
>
> To eliminate (or at least deter) people wasting time submitting phony
> information, we can compare the state to the zip code (one DB table)
> and the zip code to the area code (another table in same DB).
>
> I can use two select statements to compare the state to zip and zip to
> area code (respectively), or I can manually create a solution so that
> the lookups are done on the client side using JavaScript. If speed
> won't be an issue, I prefer to do it using PHP/MySQL because that way
> I only have to maintain the zip, state and area code data in the DB.
>
> Having said all of that, below are two questions:
>
> 1. Will these simple lookups in each table take that long? To
> reiterate: these forms are critical and must work fast. (FYI, there
> are about 58,000 records in each table.)
>
> 2. Should I index certain fields, or perform some other MySQL admin
> task(s) to help increase the speed of the lookups either now (before
> implementation) or as regular maintenance?[/color]
[snipped]
Hello Eric,
I'd have thought the best approach would be to use both Javascript (client
side) and PHP / MySQL (server side). Reasoning:-
Assuming 90% of browsers have Javascript enabled, then you might logically
catch 90% of phony information without a lookup to the database. Thereby
speeding up corrections, and without creating uneccessary overhead.
The server side validation should still take place of course, to keep your
data clean.
Regarding your indexes, yes - they should be installed WHERE they are to be
used in your queries.
http://www.mysql.com/doc/en/MySQL_indexes.html
You can use EXPLAIN SELECT to optimize
http://www.mysql.com/doc/en/EXPLAIN.html
I hope that helps you.
D