Hi!
I have a form, where you can choose between 5 titles of books. Under it you have a submit button.
My question is:
how to make so, that when the customer has chosen a book and clicks on the submit button, the title of the book to be inserted(recorded) in a db table.
I suppose it should be smth connected with if clause and INSERT INTO , but i'm not sure for the syntax.
Thank you, very, very much for the help!!!

Use this code:
this code will execute after user clicks on the submit button.

if($_SERVER['REQUEST_METHOD']=='POST')
{
mysql_query("insert query");
}

Many thanks :)

Hi,

Shanti is very much right. You should just rephrase it. Declare a separate variable.

$selection = $_REQUEST['select'];
if($selection != null)
... Insert into database;

That's it! You might want to add some security here and validate $selection.

All the best!
References:-http://www.tutorialindia.com/php_mysql/index.php

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.