Código PHP:
   <?php require_once('Connections/connection.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $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
// *** Validar solicitud para ingresar a este sitio.
if (!isset($_SESSION)) {
  session_start();
}
 
$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
  $_SESSION['PrevUrl'] = $_GET['accesscheck'];
}
 
if (isset($_POST['log'])) {
  $loginUsername=$_POST['log'];
  $password=$_POST['pwd'];
  $MM_fldUserAuthorization = "nivel";
  $MM_redirectLoginSuccess = "Menu.php";
  $MM_redirectLoginFailed = "index.php";
  $MM_redirecttoReferrer = true;
  mysql_select_db($database_connection, $connection);
      
  $LoginRS__query=sprintf("SELECT usuario, password, nivel FROM usuarios_alumnos WHERE usuario=%s AND password=%s Union SELECT usuario, password, nivel FROM usuarios_docentes WHERE usuario=%s AND password=%s",
  GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"),  GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text")); 
   
   
   
  $LoginRS = mysql_query($LoginRS__query, $connection) or die(mysql_error());
  $loginFoundUser = mysql_num_rows($LoginRS);
  if ($loginFoundUser) {
    
    $loginStrGroup  = mysql_result($LoginRS,0,'nivel');
    
    //declare two session variables and assign them
    $_SESSION['MM_Username'] = $loginUsername;
    $_SESSION['MM_UserGroup'] = $loginStrGroup;          
 
    if (isset($_SESSION['PrevUrl']) && true) {
      $MM_redirectLoginSuccess = $_SESSION['PrevUrl'];    
    }
    $_SESSION["mivariabledesesion"]=$loginUsername;
//mivariable=$v1;
session_register("mivariabledesesion");
    header("Location: " . $MM_redirectLoginSuccess );
  }
  else {
    header("Location: ". $MM_redirectLoginFailed );
  }
}
?>    Código PHP:
   $LoginRS__query=sprintf("SELECT usuario, password, nivel FROM usuarios_alumnos WHERE usuario=%s AND password=%s Union SELECT usuario, password, nivel FROM usuarios_docentes WHERE usuario=%s AND password=%s",
  GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"),  GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text")); 
    Si entra ya se de una tabla o de otra pero ingresa a
$MM_redirectLoginSuccess = "Menu.php";
Como puedo hacer que amm si es de la tabla 2 mande a otra pagina????
Es posible o tengo q manejar logueos diferentes????
 
 




