Please help me with this session control before drinking

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
botlife
Forum Newbie
Posts: 2
Joined: Tue Dec 04, 2007 5:30 pm

Please help me with this session control before drinking

Post 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]
dancaragea
Forum Newbie
Posts: 10
Joined: Sat Oct 14, 2006 2:03 pm

Post 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
botlife
Forum Newbie
Posts: 2
Joined: Tue Dec 04, 2007 5:30 pm

Thank god

Post by botlife »

It worked, thank you for all of your help. That is what i get for using my old php books.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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.
Post Reply