helo, i'm newbie here.... i trying to make multiple login in one login page.. admin go to page admin.php and counselor goes to counselor.php.. i had try so many things n it doesn't work.. all this in database and it have it's own access level.. like admin =1 and counselor =2..

<?php require_once('Connection/cs.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}
?>
<?php
// *** Validate request to login to this site.
if (!isset($_SESSION)) {
  session_start();
}

$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
  $_SESSION['PrevUrl'] = $_GET['accesscheck'];
}

if (isset($_POST['username1'])) {
  $loginUsername=$_POST['username1'];
  $password1=$_POST['password1'];
  $MM_fldUserAuthorization = "";
  $MM_redirectLoginSuccess = "index.php";
  $MM_redirectLoginFailed = "relogin.php";
  $MM_redirecttoReferrer = false;
  mysql_select_db($database_cs, $cs);
  
  $LoginRS__query=sprintf("SELECT username1, password1 FROM `cs_user` WHERE username1=%s AND password1=%s",
    GetSQLValueString($loginUsername, "text"), GetSQLValueString($password1, "text")); 
 
  $LoginRS = mysql_query($LoginRS__query, $cs) or die(mysql_error());
  $loginFoundUser = mysql_num_rows($LoginRS);
  if ($loginFoundUser) {
     $loginStrGroup = "";
    
    //declare two session variables and assign them
    $_SESSION['MM_Username'] = $loginUsername;
    $_SESSION['MM_UserGroup'] = $loginStrGroup;	      

    if (isset($_SESSION['PrevUrl']) && false) {
      $MM_redirectLoginSuccess = $_SESSION['PrevUrl'];	
    }
    header("Location: " . $MM_redirectLoginSuccess );
  }
  else {
    header("Location: ". $MM_redirectLoginFailed );
  }
}
?>

Why not solve this with a little javascript? In the code below, after entering admin and clicking submit the admin.php page will be the form action, otherwise it will go to counselor.php.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<script type="text/javascript">
	function final_check(form) {
		if ( form.username.value == "admin" ) {
			form.action = "admin.php";
		} 
                else {
			form.action  = "counselor.php";
    		}
		form.submit();
	}
</script>
</head>
<body>
	<form name="loginform" action="" method="post">

	<table border="0" cellpadding="0" cellspacing="3" style="border-style:none;">
	<tr>
		<td>Username: </td>
		<td><input type="text" name="username" value=""></td>
	</tr>
	<tr>
		<td colspan="2" align="center"><input type="Button" value="Submit" onclick="final_check(this.form)"></td>
	</tr>
	</table>
	
	</form>
</body>
</html>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.