Page 1 of 1

Email form validation- how to validate digits?

Posted: Thu Aug 23, 2007 1:32 pm
by christylh
I'm new to PHP and I'm hoping to get a little advice.

I am creating an online form for my company's site, which is wholesale and not allowed to sell to the general public. In this form I need for our customer to put in their five digit customer numbers to successfully post a message to us.

I have a .csv database of active customer numbers and all I need for this form to do is identify if it is a valid customer number or not. ie. if someone types random digits into the field it won't work.

If a customer enters in a valid customer number it will go to a successfully sent/confirmation page, if not I need it to give an error message/warning on the form page itself.

It does not have to be more complicated than that or bring up customer info, etc. If the number isn't in the database, it simply needs to give the viewer a warning.

We do not have an ecommerce site just yet, otherwise I would be able to use its login abilities to shield us from unwanted requests, however in the meantime I just have to find something basic to work with our UNIX hosting.

What do you suggest? Thanks!

Posted: Thu Aug 23, 2007 3:17 pm
by superdezign
I'd suggest more than a 5 digit code being the only validation. You should really add some sort of level of security to that, otherwise, you might as well not even bother adding that layer.

What kind of suggestions are you after? You aren't being very specific at all.

Posted: Thu Aug 23, 2007 7:27 pm
by califdon
I'd suggest that you import the .csv customer number file into a table in your database, then try to execute a query to search for the number that was given in the form. If it succeeds, it was found and you can go ahead with the process; if the query returns a null, the number (or even some other characters) were not matched in the table and you can issue your warning. This might be a good place to use Ajax, so that you don't have to reload a new page to warn the user that the input was not validated. If you know Javascript, Ajax is really quite simple; no new language to learn!