Click to See Complete Forum and Search --> : [RESOLVED] INSERT using PHP variable


dntel
12-03-2007, 10:48 AM
Hey People,

I didnt know whether to post this in PHP or SQL because its a bit both so sorry if im in the wrong one. I've been set an assignment, and now im at the part where i have to be able to register a user by inserting their details into a database ( im using access ).

So my question is how do i read from a textbox on a form and then insert the data into a table row?

i know the syntax is something like:

INSERT INTO table_name
VALUES (value1, value2,....)

But can i replace 'VALUES (value1, value2,....)' with say, a php Variable for example:

INSERT INTO table_name $sUser = $_POST["txtUser"];

Could i do it this way? or can someone tell me the correct way to go about it? if so thanks very much, look forward to hearing from anyone :)

sstalder
12-03-2007, 11:34 AM
It would be something like this:
INSERT INTO table_name (id, txtUser, field2) VALUES (NULL, '".$_POST['txtUser']."','".$_POST['field2']."');