
May 25th, 2006, 05:15 AM
|
|
|
|
Join Date: Apr 2007
Posts: 1
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
session variable problem in HTML_QuichForm
Hi, I one newer for PHP. During my coding with "HTML_QuichForm", I encountered one sesssion problem. My source code are as below:
In file "log.in", I added two elements "username" and "password", and create one SESSION variable 'username':
php Code:
Original
- php Code |
|
|
|
<?php require_once 'HTML/QuickForm.php'; $form = new HTML_QuickFrom('loginform', 'POST', 'main.php'); $form->addElement('header', null, 'QuickForm test'); $form->addElement('text', 'username', 'Enter your name:'); $form->addElement('password', 'password', 'Enter your password:'); if ($form->validate()) { $form->process('login'); } else { $form->display(); } function login($data) { $_SESSION['username'] = $data['username']; } ?>
In the file "main.php", I want to print the SESSION variable 'username':
php Code:
Original
- php Code |
|
|
|
<?php echo $_SESSION['username']; ?>
But in the file "main.php", the compiler always reported as below:
"Undefined variable: _SESSION"
Note, I have tested that SESSION works in other cases.
Thanks in advance!
Yu
|