USERNAME:
PASSWORD:
Save Info!
Logging in…
This topic is 1 page long.
[ Profile | Posts | Contact ]
Posted at: 7/17/06 08:14 PM
Sign-Up: 02/27/04
Posts: 1,026
Hi again, What I need to know how is how to send a variable to another page (this I know how to do) and once that variable is on that page is stays on it. So on page one I send a var to page 2 which is included in page 1. This works the script knows what the var is. But this page is included on other page to so I want it to stay recognized there this does not work. I tried this with sessions also I tried sending the var to page 2 with $_POST but when I clicked on another page it was no longer recognized again. So how do I make it that page 2 keeps recognizing the var once page 2 recieved the var once? Of course if you close the browser it may stop recognizing the var.
Thanks, Loc
Posted at: 7/17/06 08:26 PM
Sign-Up: 06/26/05
Posts: 3,195
Use sessions ;)
Just set the variable...
$var = "data";
Then start the session...
session_start()
Then put the variable in the session.
$_SESSION['variable'] = $var;
Now, every page that you call on that you want the variable, start the session (don't forget to start it again, very important)...
Then set the variable from the session.
$var = $_SESSION['variable']
Hope that helped :)
PHP: Main WoogieNoogie.com
Posted at: 7/18/06 05:45 AM
thanks but I don't think this is what I need. What I do is set a variable on page 1 that is then send to page 2. Page 2 is a page that is included in all the pages (also on page 1). On page 2 there is a code that looks a bid like this:
if ($thatvarr == 1) { echo 'ok'; } else { echo 'not ok'; }
now on page 1 where this var is actually set page 2 shows 'ok' but on other page is shows 'not ok'. So I want it to be that when the var is set on page one and send to page 2 it stays on page 2. Even if you go to another page where it is included. I hope you understand me better now.
Posted at: 7/18/06 07:57 AM
Sign-Up: 09/10/04
Posts: 2,627
Sounds like another case of the http path inclusion. Do not use http:// in a require statement! It will not execute the file, it will execute the output of the page since it will make another http request. That means that any variables on the caller side wont get transfered to the included file! The solution:
Stop using http:// and use either a relative path like 'file.php' or an absolute path like '/var/www/may/changedepending/on/your/host /file.php'.
Btw, the relative paths is allways relative to the first script that calls an include. Use "require dirname(_FILE_).'/file.php'" if you want it to be relative to the file that is incudeing.
Move on to ActionScript 3! And please, drop the mysql PHP extension, it's so stale that it lacks features that is no longer considered new! Go mysqli or pdo instead.
Posted at: 7/18/06 02:06 PM
At 7/18/06 07:57 AM, henke37 wrote: Sounds like another case of the http path inclusion. Do not use http:// in a require statement! It will not execute the file, it will execute the output of the page since it will make another http request. That means that any variables on the caller side wont get transfered to the included file! The solution: Stop using http:// and use either a relative path like 'file.php' or an absolute path like '/var/www/may/changedepending/on/your/host /file.php'. Btw, the relative paths is allways relative to the first script that calls an include. Use "require dirname(_FILE_).'/file.php'" if you want it to be relative to the file that is incudeing.
thanks, this works but not if I link from another folder. e.g. :
/folder1/folder2/folder3/Page1.php
needs to have a require to page 2 which is in folder:
/login/Page2.php
How can I get it to require something in a case like this?
Posted at: 7/18/06 07:49 PM
I searched some more on google and I found this
<?php include_once FP_FILE_ROOT.'/path/to/file';?>
and
require ($_SERVER["DOCUMENT_ROOT"]."/path/to/file. php");
None of these worked. Is it beacause they are for higher versions then php 4.4.2 or is it because I did something wrong with the path? (If you want to know what I want check my previous reply.)
Posted at: 7/18/06 07:58 PM
Maybe try this...
include("../login/Page2.php");
The ../ goes up one level.
Posted at: 7/18/06 08:07 PM
At 7/18/06 07:58 PM, WoogieNoogie wrote: Maybe try this... include("../login/Page2.php"); The ../ goes up one level.
Well thanks but it does not work I linked to page 2 that is in /folder1/page2.php from a file in the root directory (where the map login is in) with this code:
include(".. /folder1/page2.php");
but it does not work. Also if I want to do that thingy I explained in a previous post (different directory) this wont work right?
Posted at: 7/18/06 08:20 PM
Sign-Up: 06/07/05
Posts: 4,561
include("../folder1/page2.php"); you cant have space's.
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
All times are Eastern Standard Time (GMT -5) | Current Time: 08:34 AM
<< Back