0

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.

4
Contributors
8
Replies
9
Views
5 Years
Discussion Span
Last Post by rse
0

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']."' />";


?>

Edited by HITMANOF44th: n/a

0

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);
0

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

Edited by broj1: n/a

0

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.

0

Sorry not empty. I got Undefined index.

0

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

0

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.