Page 1 of 1

passing variable using href

Posted: Mon Nov 29, 2004 3:07 am
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?

Posted: Mon Nov 29, 2004 3:13 am
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.

Posted: Mon Nov 29, 2004 3:15 am
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. :)

Posted: Mon Nov 29, 2004 3:22 am
by Cryptkeeper
First of all, thanks for your fast reply!
And secondly, thanks for the code... it works now :)