Re: [PHP] Passing variables between pages
- From: nrixham@xxxxxxxxx (Nathan Rixham)
- Date: Sun, 21 Sep 2008 23:19:29 +0100
Robert Cummings wrote:
On Sun, 2008-09-21 at 20:39 +0100, Stut wrote:On 21 Sep 2008, at 18:13, Nathan Rixham wrote:tedd wrote:I don't think you're missing the point Nathan, I think you've hit it on the head. This technique does not solve the problem of passing variables between requests. I think the only benefit here is to avoid having to repost data by including the next script rather than bouncing off the browser.At 8:31 PM +0100 9/20/08, Nathan Rixham wrote:Am I missing something here..?Yes. You are missing the point.This is exactly the same; you don't need $_SESSION's in this case because all you're doing is POST'ing the data every time..And that's what you are missing -- it's not continued POSTing!
Follow closely,
http://www.webbytedd.com/bb/php-run-php/
While I'm using a Submit Post button to go from this script to the next script I am NOT sending any data via the POST. To prove it, use FF and see what's passed.
All data is passed/available to the next script because the next script is an include.
For example, this parent script has the variable:
$test = "This is a test";
And the next script (either a.php, or b.php, or c.php -- your choice) simply echo's $test.
Please note, the contents of the variable $test was NOT passed via a POST, but rather retained because the parent script included the next script.
Do you see the difference?
Here's another example presenting the same technique in a different way:
http://www.webbytedd.com/bb/tedd/index.php
All the variables remain intact AND there is nothing in the REQUEST, SESSION nor COOKIE arrays.
I have a hard time trying to get people to understand this simple concept. It's so simple that people often overlook how powerful it is.
For example, with a little forethought, I think there isn't a script I've written that I could not have used this technique and dispensed with SESSION's all together. That's pretty powerful, don't you think?
Do you understand what I'm doing now?no ill-intention meant.That's Okay -- I realize you meant no ill-intent.
Neither do I -- I realize that occasionally simple concepts are hard for you smarter guys to get because you have to dumb down a lot to consider what we're talking about. But I think it's an interesting concept to consider.
Cheers,
tedd
at it's simplest is this correct..?
index.php
<?php
$variables = $_POST;
include 'anotherscript.php';
?>
anotherscript.php
<?php
print_r( $variables ); //include has access to $variables from parent
print_r( $_POST ); //include has access to post data as well
?>
I'm struggling to follow here I thinks! lol
Or maybe I'm missing the point.
Looks like a basic front-end loader pattern. Data isn't passed, it's
available by virtue of being in the current request's context.
Cheers,
Rob.
so may as well just have everything in one script then..
.
- Follow-Ups:
- Re: [PHP] Passing variables between pages
- From: tedd
- Re: [PHP] Passing variables between pages
- References:
- Passing variables between pages
- From: Jason Pruim
- Re: [PHP] Passing variables between pages
- From: "Dan Joseph"
- Re: [PHP] Passing variables between pages
- From: Jason Pruim
- Re: [PHP] Passing variables between pages
- From: Jason Pruim
- Re: [PHP] Passing variables between pages
- From: "Dan Joseph"
- Re: [PHP] Passing variables between pages
- From: tedd
- Re: [PHP] Passing variables between pages
- From: Nathan Rixham
- Re: [PHP] Passing variables between pages
- From: tedd
- Re: [PHP] Passing variables between pages
- From: Nathan Rixham
- Re: [PHP] Passing variables between pages
- From: Stut
- Re: [PHP] Passing variables between pages
- From: Robert Cummings
- Passing variables between pages
- Prev by Date: Re: [PHP] Passing variables between pages
- Next by Date: Re: [PHP] Associative array issues with loading values after initialization
- Previous by thread: Re: [PHP] Passing variables between pages
- Next by thread: Re: [PHP] Passing variables between pages
- Index(es):