Jump to content

PHP sessions query


Go to solution Solved by PaulRyan,

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 :)

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.