I managed starting a session and store some data when a user login to the system. The user can edit his/her prifile by clicking on edit, then some of the data will show in the edit form. Now I have the form with empty fields and I need to get the users data from the session to show in the edit form. Now I have a function for every action for example: login(), edit().., I set the $_SESSION variabls for email and password inside function login, I need to get them back inside function edit, but I get error undefined index Email: this is the code for setting $_SESSION inside login():

$_SESSION['Email']=$HTML['email'];// I was able to print the values

I tried this inside function edit():

echo $_SESSION['Email'];

I got error: Undefined index: Email

Thanks in advance.

6 Years
Discussion Span
Last Post by rse

im not really clear what you mean
i think you mean you
want to put the session variable into a form so user can edit it


echo "<input name=\"email\" type=\"text\" value='".$_SESSION['Email']."' />";


Edited by HITMANOF44th: n/a


also from the looks of it you are setting a array form the email
are the values filling in the array the right way when you run print_r

echo print_r($HTML);

Do you have session_start() function at the beginning of your script? If not it won't work. Check the $_SESSION contents with


and compare it with the value of $HTML


Edited by broj1: n/a


I get empty array when I print $_SESSION. I started the session, and I set the variables inside function login. I tried to get them back from inside function edit, but I got empty values.


Sorry not empty. I got Undefined index.


I bet broj1 is right - sounds like no session_start(). Even if the HTML vars were empty, the session vars should exist.


Thanks, it was one of the set_ini functions.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.