0
$sql="SELECT * FROM accounts,adminaccount WHERE accounts.emailaddress='$username' and accounts.password='$password' or adminaccount.emailaddress='$username' and adminaccount.password='$password'";

$result = mysql_query($sql);

$count=mysql_num_rows($result);

$row = mysql_fetch_assoc($result);

$usertype = $row['usertype'];


if($count==1)
{
	
	$_SESSION['usertype']= $row['usertype'];
	$_SESSION['id'] = $row['id'];
	if($usertype == "admin")
	{
	header("location:indexadmin.php");
	}
	else
	{
	header("location:indexmember.php");
	}
}
else
{
header("location:index.php?page=loginfail.php");
}

?>

I wanted it to go into indexadmin.php location if the account's usertype is admin else it will head to indexmember.php. But even if i log a normal user account it will still go to indexadmin.php. Help please.

Thanks in advance.

Edited by ken.atienza: n/a

3
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by Matthew N.
0

redirects should always carry an exit; after them, although I don't know whether this will make a difference here - try it:

if($usertype == "admin"){
    header("location:indexadmin.php");
    exit;
}else{
    header("location:indexmember.php");
    exit;
}
0

Try changing to this bit of code :

$sql="SELECT * FROM accounts,adminaccount WHERE accounts.emailaddress='$username' and accounts.password='$password' or adminaccount.emailaddress='$username' and adminaccount.password='$password'";

$result = mysql_query($sql);

$count=mysql_num_rows($result);

while($row = mysql_fetch_assoc($result)){

$usertype = $row['usertype'];


if($count==1)
{
	
	$_SESSION['usertype']= $row['usertype'];
	$_SESSION['id'] = $row['id'];
	if($usertype == "admin")
	{
	header("location:indexadmin.php");
	}
	else
	{
	header("location:indexmember.php");
	}
}
else
{
header("location:index.php?page=loginfail.php");
}
}
?>

Edited by Matthew N.: n/a

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.