0
<?php
$res = mysql_query("SELECT * FROM users WHERE username = '$user' LIMIT 1");
if(mysql_num_rows($res)>0){
   $d = mysql_fetch_array($res)){
      if($pass == $d['password']){
         session_regenerate_id(); //security for changing permissions
         $_SESSION['user_id'] = $d['user_id'];
         $_SESSION['usertype_id'] = $d['usertype_id'];
         switch($d['usertype_id']){
            case 1:
               $loc = "nurse.php";
               break;
            case 2:
               $loc = "paramedic.php";
               break;
            case 3:
               $loc = "doctor.php";
               break;
            case 4:
               $loc = "medprac.php";
               break;
            case 5:
               $loc = "wardboss.php";
               break;
            case 6:
               $loc = "consultant.php";
               break;
         }
         header("Location: $loc");
      }
   }
}
?>

Edited by Dani: Formatting fixed

3
Contributors
7
Replies
8
Views
5 Years
Discussion Span
Last Post by pritaeas
0

It complain error in line 4, and ) is remove it complain { in line 5 and if removed it will complain line 6 syntax error.

0
$res = mysql_query("SELECT * FROM users WHERE username = '$user' LIMIT 1");
if(mysql_num_rows($res)>0){
$d = mysql_fetch_array($res)){
if($pass == $d['password']){
session_regenerate_id(); //security for changing permissions
$_SESSION['user_id'] = $d['user_id'];
$_SESSION['usertype_id'] = $d['usertype_id'];
switch($d['usertype_id']){
case 1:
$loc = "nurse.php";
break;
case 2:
$loc = "paramedic.php";
break;
case 3:
$loc = "doctor.php";
break;
case 4:
$loc = "medprac.php";
break;
case 5:
$loc = "wardboss.php";
break;
case 6:
$loc = "consultant.php";
break;
}
header("Location: $loc");
}
}
}
?>

Can you please help?

1

You had an exstra ) on line 3

long live 'TAB'

<?php
 $res = mysql_query("SELECT * FROM users WHERE username = '$user' LIMIT 1");
if(mysql_num_rows($res)>0)
	{
	$d = mysql_fetch_array($res);	
	if($pass == $d['password'])
		{
		session_regenerate_id(); //security for changing permissions
		$_SESSION['user_id'] = $d['user_id'];
		$_SESSION['usertype_id'] = $d['usertype_id'];
		switch($d['usertype_id'])
			{
			case 1:
				$loc = "nurse.php";
				break;
			case 2:
				$loc = "paramedic.php";
				break;
			case 3:
				$loc = "doctor.php";
				break;
			case 4:
				$loc = "medprac.php";
				break;
			case 5:
				$loc = "wardboss.php";
				break;
			case 6:
				$loc = "consultant.php";
				break;
			}
		header("Location: $loc");
		}
	}
?>
0

Please help in correcting if after you must have runned it

You had an exstra ) on line 3

long live 'TAB'

<?php
 $res = mysql_query("SELECT * FROM users WHERE username = '$user' LIMIT 1");
if(mysql_num_rows($res)>0)
	{
	$d = mysql_fetch_array($res);	
	if($pass == $d['password'])
		{
		session_regenerate_id(); //security for changing permissions
		$_SESSION['user_id'] = $d['user_id'];
		$_SESSION['usertype_id'] = $d['usertype_id'];
		switch($d['usertype_id'])
			{
			case 1:
				$loc = "nurse.php";
				break;
			case 2:
				$loc = "paramedic.php";
				break;
			case 3:
				$loc = "doctor.php";
				break;
			case 4:
				$loc = "medprac.php";
				break;
			case 5:
				$loc = "wardboss.php";
				break;
			case 6:
				$loc = "consultant.php";
				break;
			}
		header("Location: $loc");
		}
	}
?>
-1

Show a little effort. pzuurveen already corrected it. There was no need to run it to see those mistakes.

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.