/    Sign up×
Community /Pin to ProfileBookmark

how to pass variables to a php script via a link

Hi, I am looking for a tutorial, but I am not sure what to search for.

What I want to do is understand how to pass variables to a php script via a link sent to someone in an email.

I am trying to write an email validation script and I think this is a possible way to do it.

An example of this taken from this site is:

[url]http://www.webdeveloper.com/forum/newthread.php?s=&action=newthread&forumid=16[/url]

I am not sure what is happening after the “?” I assume that the data after is assessed by the php script “newthread.php”.

If I wanted to pass a variable $age=2 and $sex=”m” to the script would I use:

….newthread.php?$age=2&$sex=m

or am I totally wrong?

I need help with this.

Thanks,

Dom.

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@GenixdeaeJun 12.2004 — go to the php site

www.php.net

and do a search in their online manual, that is probably the best source for learning about scripts and code, and it's free lol.

but the code you'd use is $_GET["var"] where var is the variable in the querystring.(querystring is the url code after a ?.)

so if you wanted to do something using your age and sex as a sample youd go.
[code=php]
<a href='page.php?age=2&sex=m'>
[/code]

so in this case you would have two get's:
[code=php]
$_GET["age"] //value = 2
$_GET["sex"] //value = m
[/code]


here is a sample of what you could do::
[code=php]
//page with the email
echo "Click <a href="[email protected]">here</a> to validate your email address."

//validate.php
if $_GET["email"] = whatever {
echo "The email address of ". $_GET["email"] ." is now valid."
}else{
echo "the email address of ". $_GET["email"] ." is not a valid one."
}
[/code]
Copy linkTweet thisAlerts:
@domukauthorJun 12.2004 — Thanks Genixdeae..
Copy linkTweet thisAlerts:
@gizmoJun 13.2004 — While you are consulting the manual, look up QUERY_STRING and parse_str I found them very useful to do the same job.
×

Success!

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