|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here! |
|
#1
|
|||
|
|||
|
pass variables from one page to another
Hi,
I have a very simple problem. I am just trying to send php variables from one page to the next. For example, I have a variable $name used in the page first.php I want the value of that variable on the next page, say second.php second.php can be accessed by a link or a submit button, whichever is more efficient. Thanks! |
|
#2
|
|||
|
|||
|
Code:
link:
<a href="second.php?name=<? echo $name ?>">link</a>
form:
<form action="second.php">
<input type="hidden" name="name" value="<? echo $name ?>">
<input type="submit">
</form>
header:
<?php
header('location:second.php?name=' . $name >;
?>
|
|
#3
|
|||
|
|||
|
Just a quick addition to Gasolene's code. This will give you the variable $name on the second page if you have register globals turned on (which you shouldn't, theres a million and one threads and articles on the net as to why not so won't add another here). If you have register globals turned off then you can get at it via $_GET ['name'] instead.
Hope this helps, -KM- |
|
#4
|
|||
|
|||
|
What if I have more than 1 variable? Actually I have about 10!
What's a good way to do it then? |
|
#5
|
|||
|
|||
|
Exactly the same as above but list each one with an ampersand (&) separating each one in the query string. eg
page.html?var1=1&var2=2&var3=3...etc Hope this helps, -KM- |
![]() |
| Viewing: Dev Articles Community Forums > Programming > PHP Development > pass variables from one page to another |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|