Jump to content

Form Help


garrickplaisted

Recommended Posts

Hello all,

    I am new to php & MySQL and need a little help. I am sure this issue may be very easy for most of you but here it goes. I am going to have a form with a single field and a submit button.

<form action="" method="get">
<label name="number" value="Please enter number">Please enter number:</label>
    <input type="text" />
    <input type="submit" value="Check Results"></button>
</form>

When submitted I would like the form to query the database and return a message and echo the "group" field of the database if the data entered matches the data in "number" field in the database. I believe I need to use the SELECT statement to get this done. I have setup a database named="number_entry" with a table named="tbl_number" and 3 fields 1) "id" = INT NULL AUTO_INCREMENT PRIMARY KEY 2) "number" = TEXT 3) "group" = TEXT. I have made a connection to the DB fine. I am just not sure how to use the select statement in conjunction with the form so when a user enters a number it determines if it matches the number in the "number" field of the database. I hope I gave enough information. If someone could graciously help me that would be great.

Link to comment
Share on other sites

a few things,

 

first of all your html elements are missing some vital things.

<label> is connected to the ID of another form element so you need to provide that. for instance

<label for="monkeys">lalala</label>

Second your input element needs a name for instance:

<input type="text" name="monkeys" id="monkeys" />

notice the id i gave that makes the connection with the label.

 

As far as how to work with a database, have a look at the tutorial section, There is a nice tutorial there named 'database handling' if i am correct.

 

Good luck!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.