Jump to content

session problem help me please


azeem123456

Recommended Posts

i am setting session for a user

when a user login it redirect to staff.php file in the start of staff.php there msg should display welcomes to the staff area and my user namee

i mean if i login with name azeem then it shud say welcome to staff area ,azeem

problem is this when i hit login button it takes me to staff.php area with this warning or error msg kindly help methis is the msg i got

Staff Menu

Welcome to staff Area.,

Notice: Undefined index: username in C:\wamp\www\az\staff.php on line 14

this is my few lines of code where i set my session

$username = trim(mysql_prep($_POST['username']));
	$password = trim(mysql_prep($_POST['password']));
	$hashed_password = sha1($password);

	if ( empty($errors) ) {
		$query = "SELECT id,username ";
		$query .= "FROM users ";
		$query .= "WHERE username = '{$usrname}' ";
		$query .= "AND hashed_password ='{$hashed_password}' ";
		$query .= "LIMIT 1";

		$result_set=mysql_query($query);
		confirm_query($result_set);
		if(mysql_num_rows($result_set)==1){
			$found_user=mysql_fetch_array($result_set);
			$_SESSION['user_id']= $found_user['id'];
			$_SESSION['username'] =$found_user['username'];

			redirect("staff.php");
	} else {
		$message="username/Password combination incorrect.<br/>
		check may be caplocks is on and try again.";
		}

 

and in staff.php i m calling it this session is like this

<td width="891" align="left" bgcolor="#FFFFFF" id="pages">
                    <h2>Staff Menu</h2>
                    <p>	Welcome to staff Area.,<?php echo $_SESSION['username'];?></p>

 

 

Link to comment
https://forums.phpfreaks.com/topic/194953-session-problem-help-me-please/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.