/    Sign up×
Community /Pin to ProfileBookmark

Retrieving data stored in URL

I know how to use “echo $_get” to grab a piece of data stored in the url, e.g. google.com?page=[b]5[/b].

I would be able to make my webpage show:
You are on page [b]5[/b]

However I am having issues taking that url data and using it within the script.

[CODE]$result = mysql_query(“SELECT * FROM users WHERE email=”echo $_GET[“email”)””;[/CODE]

This is sort of what I want it to do, apart from I need the mysql query to bring back the array where column “email” equals the bit in my URL: google.com?email=[b][email protected][/b]

I’m sure it’s deadly simple, but as I have never learnt PHP – all I have is common sense and logic!

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@NogDogApr 23.2010 — First, you should never put user-supplied (or any external) data directly into a query, as it leaves you vulnerable to SQL injection errors/attacks, so you should escape the input with the appropriate mechanism for the DB interface being used.
[code=php]
$sql = sprintf(
"SELECT * FROM users WHERE email='%s'",
mysql_real_escape_string($_GET["email"])
);
$result = mysql_query($sql);
[/code]
Copy linkTweet thisAlerts:
@klanga2049authorApr 23.2010 — I could kiss you! Thank you! It's working perfectly.
×

Success!

Help @klanga2049 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,
)...