garrickplaisted Posted August 15, 2011 Share Posted August 15, 2011 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 https://forums.phpfreaks.com/topic/244863-form-help/ Share on other sites More sharing options...
cssfreakie Posted August 15, 2011 Share Posted August 15, 2011 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 https://forums.phpfreaks.com/topic/244863-form-help/#findComment-1257875 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.