Buenas noches amigos , me gustaria sabes si me pueden ayudar lo que pasa que eh tratado de crear un login de 3 niveles, administrativo , docente , alumno lo cual al momento que acceso a administrativo lo hace bien y ala hora que lo hace alumno lo hace bien pero solo al 1er registrado y con los demas no ingresa? =S quisiera saber cual es mi problema dejo el codigo.
index.php
Código PHP:
Ver original<HTML><HEAD>
<TITLE>ACCESO</TITLE></HEAD>
<script language="JavaScript" >
function valida_envia(){
if (document.fvalida.nivel.selectedIndex==0){
alert("debe seleccionar un nivel.");
document.fvalida.nivel.focus();
return 0;
}
alert("muchas gracias por enviar el formulario.");
document.fvalida.submit();
//document.fvalida.interes.focus();
}
</script>
<html>
<head>
<title>Autentificación PHP</title>
<style type="text/css">
<!--
.Estilo1 {color: #000000}
-->
</style>
</head>
<body bgcolor="#006633">
<div ></h1></div>
<body bgcolor="#008000">
<table width="959" border="1.5" align="center" bordercolor="black">
<tr>
<td colspan="2"><img src="fondo.jpg" alt="Sistema" width="971" height="201" class="imagen" /></span></td>
</tr>
<tr>
<td colspan="2" bgcolor=""><div align="center" ><span style="color:#FFF;margin-bottom:0px;font-size:37px;font-weight:bold;"><span style="font-weight:bold;"><big><blink><font color="#66FFFF"><span style="color: #ffffff; text-shadow: -1px -1px 1px #CCCCCC;">TECNOLOGIA WEB II </div></td>
</tr>
</td>
</tr>
<tr><tbody><tr>
</tr>
<tr>
<tr >
<td height="200px" valign="top" style="font-family:Arial, Helvetica, sans-serif;padding-left:30px;padding-right:20px;">
<table >
</td>
</tr>
<tbody></tr>
<tr >
<td >
<td colspan="2" style="font-weight:bold" ></td>
</tr>
<body bgcolor="#CCFFFF">
<FORM action="entrar.php" method="POST" name="fvalida">
<TABLE width="90%" cellspacing="0" border="0" cellpadding="0" align="center" background="azul.jpg">
<BR>
<TR>
<td colspan="2" style="font-weight:bold" ><span class="Estilo1"><center><font color="#FFFFFF"><h2>Acceso al Sistema</span></td>
</tr>
<TR><TR>
<TD colspan="2"> </TD>
</TR>
<TD><font color="#333333"><b> <font color="#000000">Nivel</b></font></TD>
<TD><font color="#333333">
<SELECT name="nivel">
<option value="001">Administrador</option>
<option value="002">Docente</option>
<option value="003">Alumno</option>
</SELECT>
</font></TD>
</TR>
<TR>
<TD ><font color="#333333"> <font color="#000000">Usuario</font></TD>
<TD><font color="#333333">
<INPUT type="text" name="txtusuario" size="20" maxlength="20">
</font></TD>
</TR>
<TR>
<TD ><font color="#333333"> <font color="#000000">Contraseña</font></TD>
<TD><font color="#333333">
<INPUT type="password" name="txtcontrasena" size="20" maxlength="20">
</font></TD>
</TR>
<TR>
<TD colspan="2"><font color="#333333"> </font></TD>
</TR>
<TR>
<TD colspan="2" align="center"> <INPUT type="submit" name="aceptar" value="Aceptar"></TD>
</TR> </tr>
</table></td>
<td width="400" bgcolor="#006633"><div align="center">
<p><img src="texasteach_kids.jpg" width="400" height="200" /></p>
</div></td>
</tr>
</TABLE>
</form>
</body>
<br>
<br>
<font color="#FFFFFF">
<center
<p><img src="baner.jpg"/></p></center>
</HTML>
Creo que el problema es en entrar.php
serian muy amables de corregirme este codigo profavor y si es mejor la opcion encriptar tambien.
Creo que este es el codigo que genera problemas.
Código PHP:
Ver original $vlogin=$row[1];
$claved=desencriptar($row[2]);
if($vlogin==$usu && $claved==$cla)
{
// if($row[4]=='A')
//{
header ("Location: administrador.php"); $_SESSION['idusuario']=$row[0];
entrar.php
Código PHP:
Ver original<?php
//require_once("conexion.php");
$nivel=$_POST['nivel'];
$usu=$_POST['txtusuario'];
$cla =($_POST['txtcontrasena']);
include("encriptar.php");
include("conexion.php");
//**************** administrativo********************/
if ($nivel=="001")
{
$ssql="SELECT * FROM administrativo WHERE adm_apenom = '$usu'";
{
$vlogin=$row[1];
$claved=desencriptar($row[2]);
if($vlogin==$usu && $claved==$cla)
{
// if($row[4]=='A')
//{
header ("Location: administrador.php"); $_SESSION['idusuario']=$row[0];
}
else
{
header ("Location: index.php?errorInhabi=Usuario Inhabilitado!!"); }
}
else
{
header ("Location: index.php?error=Usuario no Existe!!"); }
}
//**************************************************docente
if ($nivel=="002")
{
$ssql="SELECT * FROM docentes WHERE doc_apenom = '$usu'";
{
$vlogin=$row[1];
$claved=desencriptar($row[2]);
if($vlogin==$usu && $claved==$cla)
{
// if($row[4]=='A')
//{
header ("Location: docente.php"); $_SESSION['idusuario']=$row[0];
}
else
{
header ("Location: index.php?errorInhabi=Usuario Inhabilitado!!"); }
}
else
{
header ("Location: index.php?error=Usuario no Existe!!"); }
}
//**************************************************docente
if ($nivel=="003")
{
$ssql="SELECT * FROM alumnos WHERE ALUCODIGO = '$usu'";
{
$vlogin=$row[0];
$claved=desencriptar($row[7]);
if($vlogin==$usu && $claved==$cla)
{
// if($row[4]=='A')
//{
header ("Location: alumno.php"); $_SESSION['idusuario']=$row[0];
}
else
{
header ("Location: index.php?errorInhabi=Usuario Inhabilitado!!"); }
}
else
{
header ("Location: index.php?error=Usuario no Existe!!"); }
}
$_SESSION['alumnos']=$_POST["txtusuario"];
$_SESSION['contrasena']=$_POST["txtcontrasena"];
//header("Location: guardaralumno.php");
//**********************************
?>