Page 1 of 1

Please help me with this session control before drinking

Posted: Tue Dec 04, 2007 5:42 pm
by botlife
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


For the life of me I cannot get this variable to parse to another page. I am trying to parse variables using sessions for a four page application and it isn't working. No matter what I try or do. 

[b]On Page 1 (which is a redirector that works fine)[/b]

Code: Select all

session_start();
session_register ('loan2');
$loan2 = $_POST[loan];


if ($loan2 =="equity")
{
header('Location: http://www.banksbid.com/equity1.php');
}
On Page 2 I have session_start(); in the head tags and this in the body

Code: Select all

<? 
print $HTTP_SESSION_VARS["loan2"]; print $loan2; 
if (!isset($loan2)) {
print "crap" ; }
 ?>
I tried everything and cannot get the thing to work. PLEASE HELP before I kill my computer.

Nick :(


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Tue Dec 04, 2007 5:51 pm
by dancaragea
Unless you use an ancient php version don't use session_register().
Use the $_SESSION superglobal array.
Instead of doing session_register($somevar) simply do $_SESSION['somevar']=$somevar; to save the variable in the session then
$somevar=$_SESSION['somevar'] to read it.

Of course, you would save it in the first file after you read the var from $_POST

Thank god

Posted: Tue Dec 04, 2007 6:28 pm
by botlife
It worked, thank you for all of your help. That is what i get for using my old php books.

Posted: Tue Dec 04, 2007 7:34 pm
by volka
If you're going to buy a more recent book make sure it targets php 5.
http://php.net/ wrote:PHP 4 end of life announcement
[13-Jul-2007]

Today it is exactly three years ago since PHP 5 has been released. In those three years it has seen many improvements over PHP 4. PHP 5 is fast, stable & production-ready and as PHP 6 is on the way, PHP 4 will be discontinued.