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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.