/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] INSERT using PHP variable

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:

[code=php]INSERT INTO table_name $sUser = $_POST[“txtUser”];[/code]

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 ?

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@sstalderDec 03.2007 — It would be something like this:
[code=php]INSERT INTO table_name (id, txtUser, field2) VALUES (NULL, '".$_POST['txtUser']."','".$_POST['field2']."');[/code]
×

Success!

Help @dntel spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...