php sessions

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
binoy3012
Forum Newbie
Posts: 4
Joined: Tue May 13, 2003 1:49 am

php sessions

Post by binoy3012 »

hi!
I'm making a student registration system using mysql and php.The first page has the username and password for admin/employee log-in, and i've used session for that entry.
With the employee log-in, the second page has the Student ID entry and i used session for this also, but im getting errors.I want to know how to use a session inside another session.I may be wrong in doing this as im using php for the first time, or is it that, we have to declare all the sessions together or something like that, which im not sure,but would appreciate if anyone could help me with the exact syntax.thanks! (* the first session is for the admin/employee log-in, and the second one is for the student ID).
Czar
Forum Commoner
Posts: 58
Joined: Sun Dec 29, 2002 11:17 am

Post by Czar »

I would put it this way;

Once logged in as an employee and authenticated via database, set session var for it.

Code: Select all

<?php

$_SESSION['login_employee'] = "true";
?>
Inside the next page (student id entry) just set another var for it inside same session.

Send studentID from form to page itself and set it as session var:

Code: Select all

<?php
if(isset($_SESSION['login_employee'])) #check employee login
{
if(isset($studetID)) 
{
$_SESSION['studentID'] = $studentID;
}
print_student_form(); # student form function, action: PHP_SELF
}
else
{
header("location:loginpage.php?message=unauthorized"); #redirect to login page if session is not set.
}
?>
binoy3012
Forum Newbie
Posts: 4
Joined: Tue May 13, 2003 1:49 am

php session

Post by binoy3012 »

thanks,
i will try and see if it works!
Post Reply