Forum Moderators: open

Message Too Old, No Replies

Unique Database Entry Validation

Unique Database Entry Validation

         

jlommori

3:14 am on Jun 15, 2007 (gmt 0)

10+ Year Member



I'm new javascript and AJAX, but have a far knowledge of SQL, PHP and HTML.

I'm using a PHP powered form to add entries into a SQL database. I would like to have javascript and AJAX confirm that the ID # of the new item is not already in the database?

Any help is greatly appreciated.

coopster

3:16 am on Jun 15, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



The database is on the server so the logic will need to reside on the server, jlommori. You program the client to interact with the server via your JavaScript code.

colandy

8:07 am on Jun 15, 2007 (gmt 0)

10+ Year Member



We probably need a bit more detail (example code) as to what your trying but here's a guide as to what you need to do.

1. Create HTTPRequest Object
2. Using the obj.OPEN("GET",URL+?id=yourfieldname, True) call the PHP validation Page
3. Within the PHP ensure the validation page returns something (eg....0 non-existent ID and 1 if it exists).
4. AJAX obj picks up the echoed response and does whatever it likes with it.

Not sure how much AJAX you know but plenty of threads on here will help.