PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old June 14th, 2004, 02:51 PM
phpNoob phpNoob is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Location: Memphis, TN
Posts: 3 phpNoob User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to phpNoob
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!

Reply With Quote
  #2  
Old June 14th, 2004, 04:57 PM
Gasolene Gasolene is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 1 Gasolene User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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 >;
?>

Reply With Quote
  #3  
Old June 14th, 2004, 05:22 PM
kode_monkey kode_monkey is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 367 kode_monkey User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 m 21 sec
Reputation Power: 12
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-

Reply With Quote
  #4  
Old June 15th, 2004, 10:06 AM
phpNoob phpNoob is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Location: Memphis, TN
Posts: 3 phpNoob User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to phpNoob
What if I have more than 1 variable? Actually I have about 10!
What's a good way to do it then?

Reply With Quote
  #5  
Old June 15th, 2004, 11:44 AM
kode_monkey kode_monkey is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 367 kode_monkey User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 m 21 sec
Reputation Power: 12
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-

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > pass variables from one page to another


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.

© 2003-2014 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap