Learning PHP

Status
Not open for further replies.

thejeremy

In Runtime
Messages
104
Location
Chicago IL
Here's the structure of my program.

A user will login (login.php), they will read some instructions (instructions.php), and they will finally be directed to answer some questions in a step by step survey (questions.php). My question is, how can I access variables that were entered back in login.php, such as username or email address for example, when the user has already left that page? I need to insert the answer from each question into the database as it is entered, and I need to locate the current user's table entry and access the MySQL database to do so. Is there some global variable type I can initiate to hold these values? I'm sorry if this is a noob question, I'm still learning.

Help is appreciated.
 
you need to set them as session veriables and start a session in each page you will be using them. at the top of each page the global veriables will be used, session veriables, you will need to start the session like so <?php session_start(); ?> than back at the page that you first get the username and email you will transfer those into session veriables by declaring them like this

$_SESSION['username'] = $username;
$_SESSION['email'] = $email;

and you will then from then on when needed call them as $_SESSION['username'];. starting the session on each page is very important though or it will not work even the best of us forget this step sometimes.

hope that helps
 
i was just readin about $_SESSION variables before you posted. this looks like it'll do what I need...thnx for comin through for me :)

If I have more PHP questions I'll just tack em on to the end of this thread.
 
ok no problem just ask me ill be here i have lots of experience with php :) good luck.
 
Status
Not open for further replies.
Back
Top Bottom