passing variable using href

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Cryptkeeper
Forum Newbie
Posts: 17
Joined: Wed Nov 10, 2004 3:05 am

passing variable using href

Post by Cryptkeeper »

Hi.

Is it possible to pass a variable from one php file to another php file using href?
I know u can use sessions or cookies but I need to pass the variable through an url.
I tried " href=var.php?variable='test' " but that didn't work.
Can you guys help me?
User avatar
phpScott
DevNet Resident
Posts: 1206
Joined: Wed Oct 09, 2002 6:51 pm
Location: Keele, U.K.

Post by phpScott »

I do that quite frequently.

Code: Select all

<a href="somePage.php?someVarName=someVarValue&var2=var2Value">somePage</a>
and it works quite happily but remember your varaible is then coming in via the GET method and not POST.
Steveo31
Forum Contributor
Posts: 416
Joined: Sun Nov 23, 2003 9:05 pm
Location: San Jose CA

Post by Steveo31 »

It's not

<a href="page.php?page='var'">Link</a>

It's

<a href="page.php?page=var">Link</a>

No ' in the URL variables. :)
Cryptkeeper
Forum Newbie
Posts: 17
Joined: Wed Nov 10, 2004 3:05 am

Post by Cryptkeeper »

First of all, thanks for your fast reply!
And secondly, thanks for the code... it works now :)
Post Reply