View Full Version : php transfering variables from 1 page to anouther
v_mcglynn
04-03-2002, 11:38 AM
I have knowlege is ASP and have now been thrown into PHP.
In asp you can pass a variable at the end of a link the the next page.
In php this doesn't seem to work.
Is it possible and if so how?
I have <a href="page1.php?<?$pic='variableName'?>">link</a>
How would I call it on the next page?
Or better yet is there a way to dump all your variables from a page?
I think that you can simply refer to the variable as $variablename in the PHP script.
example:
<?php echo $variablename; ?>
would return the variable in the html file.
Does that help?
Originally posted by v_mcglynn
I have <a href="page1.php?<?$pic='variableName'?>">link</a>
i am still a newbie to PHP but i am confused by your code listed above,
doesn't it return something like this when the page is sent?:
<a href="page1.php?">link</a>
and i learnt this the hard way, always use urlencode($variablename) when passing variables in the url so u don't get problems when they contain spaces etc
Garth Farley
04-04-2002, 09:50 AM
I think he's missing the quotes around the echo statement.
Try
<a href="page1.php?<? echo "$variableName"; ?>">Link</a>
Garth Farley
v_mcglynn
04-09-2002, 07:49 AM
They changed things a little on me and it's still not working.
Here's what I have now...
<a href="javascript:popupWindow('popUp.php?<? echo 'search'; ?>')">Search all Charts</a>
Garth Farley
04-10-2002, 04:34 AM
<a href="javascript:popupWindow('popUp.php?<? echo "$search"; ?>')">Search all Charts</a>
This should output "popUp.php?search_term"
But I suggest for your ease at accessing this variable on the next page (popUp.php) to have
<a href="javascript:popupWindow('popUp.php?search=<? echo "$search"; ?>')">Search all Charts</a>
so on popUp.php, the original $search variable will be called $search too.
Use double quotes, as single quotes mean the variable won't be inserted.
Garth Farley
v_mcglynn
04-10-2002, 06:38 AM
Thanks for the help guys
vBulletin® v3.8.5, Copyright ©2000-2010, Jelsoft Enterprises Ltd.