Código PHP:
<?php
session_start();
include_once "conexion.php";
include_once "function_login.php";
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Custom JavaScript Dialog Boxes</title>
<link rel="stylesheet" type="text/css" href="dialog_box.css" />
<script type="text/javascript" src="dialog_box.js"></script>
</head>
<body>
<?php
$id = $_POST['username'];
$n = 1;
$user = strtolower($id{$n - 1});
switch ($user)
{
case "a":
$_POST['password'] = md5($_POST['password']);
if(verificar_login_a($_POST['username'],$_POST['password'],$result) == 1)
{
$_SESSION['userid'] = $result->id_user;
header("location:admin/index.php");
}
else
{
//header("location:index.php");
?>
<script type="text/javascript">
location.href="index.php";
</script>
<script type="text/javascript" src="dialog_box.js">
javascript:showDialog('Error','User o clave incorrecto.','error',2)
location.href="index.php";
</script>
<?php
}
break;
case "e":
$_POST['password'] = md5($_POST['password']);
if(verificar_login_e($_POST['username'],$_POST['password'],$result) == 1)
{
$_SESSION['userid'] = $result->id_alumno;
header("location:alumno/index.php");
}
else
{
header("location:index.php");
}
break;
default:
header("location:index.php");
}
?>
</body>
</html>