Current location: Hot Scripts Forums » Programming Languages » PHP » variables lost on redirect?


variables lost on redirect?

Reply
  #1 (permalink)  
Old 05-30-05, 09:19 PM
lordy lordy is offline
Newbie Coder
 
Join Date: May 2005
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
variables lost on redirect?

A simple question, are variables lost on a redirect?

On a site I am designing, when I submit to one page I can display the output of a variable but when I then redirect the user to a new page the variable is lost. Is there any way around this? redirect but save the variable? If so, how?

Thanks
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 05-31-05, 12:59 AM
Jaffizzle Jaffizzle is offline
Newbie Coder
 
Join Date: May 2005
Posts: 61
Thanks: 0
Thanked 0 Times in 0 Posts
I think you would need to use sessions.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 05-31-05, 09:40 AM
dennispopel dennispopel is offline
Coding Addict
 
Join Date: Mar 2005
Posts: 263
Thanks: 0
Thanked 0 Times in 0 Posts
You could pass the variables in the redirection URL. To answer your question: yes, they are lost. Redirection works as follows:

1. Script A redirects to another URL (of script B)
2. Script A ends, headers are sent to force the browser to open the redir URL
3. Script B starts, but with the params passed in the redir URL
__________________
onPHP5.com - PHP5: Articles, News, Tutorials, Interviews, Software and more
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 06-01-05, 12:43 AM
lordy lordy is offline
Newbie Coder
 
Join Date: May 2005
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
thanks for the help guys, all working now (ended up using sessions)

and ta for clarification on variables being lost!
have to keep that one in mind...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #5 (permalink)  
Old 06-01-05, 06:23 PM
dennispopel dennispopel is offline
Coding Addict
 
Join Date: Mar 2005
Posts: 263
Thanks: 0
Thanked 0 Times in 0 Posts
Hello,

Of course, sessions are more convenient, but you should be aware that if the vvisitor opens several windows, the session variables may get overwritten by each other. f you use URL parameters then every window will follow its own redirection without interfering with others.
__________________
onPHP5.com - PHP5: Articles, News, Tutorials, Interviews, Software and more
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #6 (permalink)  
Old 06-01-05, 08:09 PM
lordy lordy is offline
Newbie Coder
 
Join Date: May 2005
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
of course, I will have to keep that in mind

thanks
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Server side variables Puno PHP 13 08-13-05 11:22 PM
recording variables wings PHP 4 03-18-05 06:12 PM
formmail problem gscraper Perl 12 08-27-04 04:06 AM
REdirect with adding variables imlek Script Requests 0 08-22-04 03:06 AM
help with displaying variables tisza PHP 9 12-22-03 06:08 PM


All times are GMT -5. The time now is 12:48 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.