Reputation: 3
Hi I am trying to implement a two step approach to addding data to a table, for example in my table companies...
I have created 2 PHP pages, called step 1 and step 2, step 1 collects basic information like company name, then the idea is step 2 will collect more specific information like address.
When I save my step 1 page, it redirects to step 2, but I cant figure out how to pass some form of session variable so that page 2 knows what the companyid is.
any ideas
Upvotes: 0
Views: 51
Reputation: 1200
How to store data in a $_SESSION
:
First of all make sure session_start()
has been called on top of your page.
Store the value in the session:
$_SESSION['paramX'] = 'X';
How to get the $_SESSION variable:
$paramX = $_SESSION['paramX']
A tip to check what's in $_SESSION:
var_dump($_SESSION);
OR
print_r($_SESSION);
Upvotes: 0
Reputation: 466
save it in a SESSION variable in page1 use this
session_start();
$_SESSION['id']= $id; //the id to pass
and in the page2 you can access $_SESSION['id'] directly
Upvotes: 1