/    Sign up×
Community /Pin to ProfileBookmark

Posting Session data in a Database

I’m making a form for my website, and when a Logged in user makes a post on the form, I want their Username to be posted in the database.

I tried this on the form’s end.

[code=php]<?php

<input name=”Name” type=”hidden” id=”Name”
value= $_SESSION[‘SESS_USERNAME’]
>

?>[/code]

I even tried this code on the file that the form triggers.

[code=php]$sql= “insert into Information (Name) values (‘$_SESSION[‘SESS_USERNAME’]’) “; [/code]

None of these worked. It would either give me errors or post blanks in the field.

I’m a PHP noob, so I’m not sure how a lot of PHP functions work. So I’m sure someone here can point me in the right direction.

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@JustinNov 13.2008 — $sql= "insert into Information (Name) values ('{$_SESSION['SESS_USERNAME']}') ";

When using arrays inside quotes you need to surround it with {}.

And watch your quotes.
Copy linkTweet thisAlerts:
@StripedTigerauthorNov 13.2008 — That did the trick. Thanks alot.
Copy linkTweet thisAlerts:
@JustinNov 14.2008 — no problem. Glad to help
×

Success!

Help @StripedTiger 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 5.19,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

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

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...