Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Notice: Undefined index:

Status
Not open for further replies.

yazo

Technical User
Jun 9, 2004
3
Hello, hopefully someone can help me.
I am receiving this error on my webpage:

Notice: Undefined index: UserCookie in /var/ on line 14


And here is the getusername.php:

<?php

if (isset($_COOKIE['UserCookie']))

{

$access = $_COOKIE['UserCookie'];

$qu = "SELECT * FROM users WHERE accesshash ='$access' LIMIT 1";

}

elseif (isset($_SESSION['id']))

{

$access = $_SESSION['id'];

$qu = "SELECT * FROM users WHERE accesshash ='$access' LIMIT 1";

}

else

{

$access = $_COOKIE['UserCookie'];

$qu = "SELECT * FROM users WHERE accesshash ='$access' LIMIT 1";

}



$resultuser = mysql_query("$qu");

$rowuser = mysql_fetch_array( $resultuser );

$_SESSION['pp'] = $rowuser['email'];

$_SESSION['uid'] = $rowuser['userid'];

$_SESSION['gp'] = $rowuser['usergroup'];

if ($_SESSION['gp'] == 'super_maintenance')

{

$_SESSION['gp'] = 'admin';

}

$_SESSION['username'] = $rowuser['username'];

?>



Thanks, hopefully someone can shed some light on this, i cant get rid of this error.
 
You check if the cookie is set ([tt]if (isset($_COOKIE['UserCookie']))[/tt]) and then, if it is not (else part of your code) you try to assign the cookie value to the $access variable. You're not thinking this through. If you set $access to the value of the cookie if the cookie exists, then you shouldn't do the same if the cookie doesn't exist.

___________________________________________________________
[small]Do something about world cancer today: Comprehensive cancer control information at PACT[/small]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top