View Full Version : Check answer in database

02-24-2012, 03:50 PM

I have PHP forms and a MySQL database.

The user enters their name.

What is your name? [ FORM ]

What I would then like to do is then ask the user to enter their input into forms - say I ask a question:

What does C in CPU stand for? [ FORM ]

The answer is stored in the database and if they answer correctly it adds 1 beside the user's name.

Does anyone know of any code / tutorial that will help me to achieve this?

02-24-2012, 04:34 PM
So are you trying to store a form into a DB? That's easily google-able, its a massively easy technique (just googling "store pho form into mysql" comes back with a ton of good results).

Or are you trying to do something different?

02-24-2012, 04:41 PM
Thanks for your post.

What I would like to do is store the answer and COMPARE the user's answer with the answer stored in the MySQL database table.

The table structure may look like this:

| id | username | question | answer | score

02-24-2012, 06:18 PM
Look at prepared statements in PHP and the insert and select statements in MYSQL.