Jump to content

PHP sessions query


JamesKoash

Recommended Posts

Hi there,

 

I'm trying to put together a multi-page form, which uses PHP sessions to store data, but am having trouble getting it working. Here is my code for the first page. (I haven't yet added any form validation or anything).

session_start();

if(isset($POST['name']))
    $_SESSION['name'] = $POST['name'];
else
    $_SESSION['name'] = "";
	
if(isset($POST['email']))
    $_SESSION['email'] = $POST['email'];
else
    $_SESSION['email'] = "";
	
if(isset($POST['businessname']))
    $_SESSION['businessname'] = $POST['businessname'];
else
    $_SESSION['businessname'] = "";

if(isset($POST['job']))
    $_SESSION['job'] = $POST['job'];
else
    $_SESSION['job'] = "";

I've even tried them all with two sets of equals symbols, as that seems to be the error I made last time I posted code on here, but that hasn't fixed it this time. In fact, it seemed to throw up more errors.

 

The page is titled page_1.php and I'm using a form tag with method="post" and action="page_1.php" to collect the data. I tried testing whether the sessions were working by creating a variable called $name, which I stated was equal $_SESSION['name'], but printing this variable didn't seem to work.

 

Help would be appreciated :)

Link to comment
https://forums.phpfreaks.com/topic/281594-php-sessions-query/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.