Simple PHP script required to query DB


I am a php newbie and require some help.

I am working with Joomla 1.5 and a chronoform component.

I have a MySQL database with a table called jos_chronoforms_data_user_details.

It has a key field called serial_number.

I have a simple HTML form that has a text box, (text box field is also called serial_number. This is required for chronoforms to repopulate a form) and a submit button. The user is asked to enter a Serial Number.

What I want help with is in writing a simple php script to do the following:

If the Serial Number entered does not = a number in the serial_number column of the DB then when submit is pressed it will redirect the user back to the blank form awaiting a correct Serial Number entry. No error message is required.

At present the form accepts any number submitted and if it = a number in that table field then it repopulates the original entry form for editing, which is what is wanted. However, if it does not match a number in that table field it opens up an empty form ready to be repopulated but with the new serial number in the the serial number field. If submit is then selected from this new form it makes a new record in the DB.

I have contacted Chronoengine, the writers of this component, but they just refer me to use a php query script.

Can anyone help please?

Sponsor our Newsletter | Privacy Policy | Terms of Service