0

i cannot pass the result of mysql_fetch_object to another function.

function sessionStartCase($challenge,$user,$pass){
 global $conn;
	$ipaddress = $_SERVER['REMOTE_ADDR'];
	$url = $_SERVER['PHP_SELF'];
	if (isset($challenge) && isset($user) && isset($pass)) {
		$password = getPasswordForCase($user);

	echo $result->case_user_id;
	//if( @mysql_num_rows($row) ) {
		//$result = @mysql_fetch_object($row);
		if (validate($challenge, $pass, $password)) {
		echo "valid";
		$result->case_user_pass;
		echo $result->case_user_id;
		session_start();
		//$_SESSION['gelCase'] = 1;
		echo $result->case_user_type;
		$_SESSION['userId'] = $result->case_user_id;
		$_SESSION['type'] = $result->case_user_type;
		$_SESSION['userName'] = $result->case_user_name;
		$_SESSION['geltime'] = time();
addLoginLog($user, $ipaddress, 'Login Successful', $url);
		if($_SESSION['type'] == 3){
			header("Location: admin.php");
		}elseif($_SESSION['type'] == 2){
			header("Location: officer.php");
		}elseif($_SESSION['type'] == 1){
			header("Location: staff.php");
		}
	} 
	
	else {
	echo "fail";
addLoginLog($user, $ipaddress, 'Login Failed', $url);
			addLoginAttempt($ipaddress);
		$error= " <p style='color:#FF0000'>User Login Failed</p>";
		return $error;
	}}
}

function getPasswordForCase($username) {
	global $conn;
	$ipaddress = $_SERVER['REMOTE_ADDR'];
	$url = $_SERVER['PHP_SELF'];
	
	if(checkIPAddress($ipaddress)) {
	//$user = escape($username);
	//$query = "SELECT * FROM user WHERE user_name='" . $user . "'";
		$query = @sprintf("SELECT * FROM case_user WHERE case_user_login ='%s'",escape($username));
		//$query="SELECT * FROM user WHERE user_name ='admin'";
		$row = caseQuery($query) or die("Unkown Error");
		if( @mysql_num_rows($row) ) {
			$result = @mysql_fetch_object($row);
			//addLoginLog($user, $ipaddress, 'Login Successful', $url);
			$userPass = $result->case_user_pass;
			
			
		}else {
	
			addLoginLog($username, $ipaddress, 'Login Failed', $url);
			
			addLoginAttempt($ipaddress);
			header("Location:index.php?error=".urlencode("Failed authentication"));
			exit;
		}
	}else{
		header("Location:index.php?error=".urlencode("Access denied.<br />You are blocked from loging in"));
		exit;
	}

	return $userPass;
}

the values that im getting in the getPasswordForCase function cannot be read in the sessionStartCase function.....can you tell me what im doin wrong?

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by whiteyoh
0

at first glance you have passed in the username to a function, where another function is called that uses $username. You havent passed username into that function again

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.