Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Computer Forums > Programmers Lounge > Programming Discussions » posting a variable to multiple pages
Closed Thread
Old 03-08-2004, 02:34 AM   #1 (permalink)
jbl
 
Newb Techie

Join Date: Mar 2004

Posts: 1

jbl

Unhappy posting a variable to multiple pages

Help Anyone. I'm a bit of a newbie with php. I want to post a variable to more than one page. Can this be done or am I looking at maybe declaring public variables? Any Advise will be helpfull.
Thanx
Julian
jbl is offline  
Old 03-09-2004, 04:47 PM   #2 (permalink)
 
Super Techie

Join Date: Dec 2003

Posts: 333

Harold III

Send a message via AIM to Harold III
Default

I think you can invoke all the pages consequently instead of at the same time. for instance, in your first page, make the submission point to the second page, and in your second page, which is a .php file, write this code (suppose your first page passes a $email variable to second page and third page):

I can't post code here cuz it'll be messed up so I copied it into a picture file.

and remember in your third page refer to that variable as $email2
Attached Images
 
__________________
I do this for Aiur. NOT YOU.
Harold III is offline  
Old 03-09-2004, 08:08 PM   #3 (permalink)
 
Monster Techie

Join Date: Jul 2003

Posts: 1,179

Emily is on a distinguished road

Send a message via AIM to Emily
Default

Or insert the variable into the page address in the link.

Quote:
<a href="http://www.address.com/page.php?variable=value">Link 1</a>

<a href="http://www.address.com/page2.php?variable=value">Link 2</a>

<a href="http://www.address.com/page3.php?variable=value">Link 3</a>
And then on each page, you can reference the variable in the address.
__________________
<a href=\"http://www.upstark.com\">www.upstark.com</a>
Emily is offline  
Old 03-09-2004, 09:04 PM   #4 (permalink)
 
Super Techie

Join Date: Dec 2003

Posts: 333

Harold III

Send a message via AIM to Harold III
Default

Quote:
Originally posted by Emily
Or insert the variable into the page address in the link.



And then on each page, you can reference the variable in the address.
AH... I didn't know you can use a variable=value in your anchor tag... thanks a lot... but anyways, I thought he was talking about once you hit the submit button, the variables will be passed to multiple php files and they are supposed to come out at the same time??? Is there any way to submit the values to several destinations at the same time?
__________________
I do this for Aiur. NOT YOU.
Harold III is offline  
Old 03-09-2004, 09:38 PM   #5 (permalink)
 
Monster Techie

Join Date: Jul 2003

Posts: 1,179

Emily is on a distinguished road

Send a message via AIM to Emily
Default

Yeah... So once you hit the submit button, the variable is passed to page1.php. And if you click a link on page1.php that leads to page2.php, the url in the anchor tag would be page2.php?variable=$value ($value is the variable passed from the original form to page1.php)

The problem with your code is that what if someone wants to go from page 2 to page 4? The form code on page 2 submits to page 3, so going to page 4 from page 2 would be impossible. But if you always link to page 4 as page4.php?variable=value (where 'value' would be a variable passed from the previous page), then you can go to page 4 from any page and still pass the variable.

Um... there was probably a much more articulate way to say that. Oh well.
__________________
<a href=\"http://www.upstark.com\">www.upstark.com</a>
Emily is offline  
Old 03-09-2004, 10:21 PM   #6 (permalink)
 
Super Techie

Join Date: Dec 2003

Posts: 333

Harold III

Send a message via AIM to Harold III
Default

I understand what you are saying. but as what I said, I was wondering whether there's a way to pass the variables to all of several php files at the very moment the user click submit, and them page1.php, page2.php, page3.php will come out at the same time in three windows... that's crazy and that was what I perceived as jbl's question.


__________________
I do this for Aiur. NOT YOU.
Harold III is offline  
Old 03-11-2004, 11:28 PM   #7 (permalink)
Larry's Avatar
 

Join Date: May 2003

Posts: 1,797

Larry has disabled reputation

Default

have the ONE button call a script, which in turn calls the other files.

actually, I re-read your original post:

"pass one variable to multiple pages"

what exactly are you trying to do? There are many solutions, but until we know what your really trying to do, we don't know what the best solution is.


Larry is offline  
Old 03-12-2004, 10:26 AM   #8 (permalink)
 
Monster Techie

Join Date: Jul 2003

Posts: 1,179

Emily is on a distinguished road

Send a message via AIM to Emily
Default

Quote:
Originally posted by Harold II
I understand what you are saying. but as what I said, I was wondering whether there's a way to pass the variables to all of several php files at the very moment the user click submit, and them page1.php, page2.php, page3.php will come out at the same time in three windows... that's crazy and that was what I perceived as jbl's question.

Oh... well that would require Javascript or some other language in addition to PHP. I thought he was talking about some kind of global variable, where he could access it on different pages.

Larry.. I agree, I'm not really sure what he's asking either.
__________________
<a href=\"http://www.upstark.com\">www.upstark.com</a>
Emily is offline  
 
Closed Thread

Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On