Hello,
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
$_SESSION['Password']=$HTML['password'];

I tried this inside function edit():

echo $_SESSION['Email'];

I got error: Undefined index: Email

Thanks in advance.

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

<?php

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


?>

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

print_r($_SESSION);

and compare it with the value of $HTML

print_r($HTML);

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.

Maybe you should post complete code so we can have a look at it.

Member Avatar for diafol

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.