Ver Mensaje Individual
  #1 (permalink)  
Antiguo 12/12/2012, 18:22
Avatar de nexus44
nexus44
 
Fecha de Ingreso: octubre-2012
Ubicación: Piura
Mensajes: 108
Antigüedad: 11 años, 6 meses
Puntos: 1
4yudenme con este codigo

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
  1. <HTML><HEAD>
  2. <TITLE>ACCESO</TITLE></HEAD>
  3. <script language="JavaScript" >
  4. function valida_envia(){
  5.  
  6. if (document.fvalida.nivel.selectedIndex==0){
  7. alert("debe seleccionar un nivel.");
  8. document.fvalida.nivel.focus();
  9. return 0;
  10. }
  11. alert("muchas gracias por enviar el formulario.");
  12. document.fvalida.submit();
  13. //document.fvalida.interes.focus();
  14. }
  15. </script>
  16. <html>
  17. <head>
  18. <title>Autentificaci&oacute;n PHP</title>
  19. <style type="text/css">
  20. <!--
  21. .Estilo1 {color: #000000}
  22. -->
  23. </style>
  24. </head>
  25. <body   bgcolor="#006633">
  26. <div ></h1></div>
  27.  
  28.  
  29.  
  30. <body  bgcolor="#008000">
  31.  
  32.   <table width="959" border="1.5" align="center" bordercolor="black">
  33.     <tr>
  34.       <td colspan="2"><img src="fondo.jpg"  alt="Sistema" width="971" height="201"  class="imagen" /></span></td>
  35.     </tr>
  36.    
  37.     <tr>
  38.       <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>
  39.     </tr>
  40.  
  41.  
  42. </td>
  43. </tr>
  44. <tr><tbody><tr>
  45.   </tr>
  46.   <tr>
  47.    
  48.  
  49.   <tr >
  50.    
  51.     <td height="200px" valign="top" style="font-family:Arial, Helvetica, sans-serif;padding-left:30px;padding-right:20px;">
  52.    
  53.     <table >
  54.   </td>
  55.   </tr>
  56.      <tbody></tr>
  57. <tr  >
  58. <td >
  59.  
  60.    
  61.      <td colspan="2" style="font-weight:bold"  ></td>
  62.       </tr>
  63. <body bgcolor="#CCFFFF">
  64.  
  65. <FORM action="entrar.php" method="POST" name="fvalida">
  66. <TABLE width="90%" cellspacing="0" border="0" cellpadding="0" align="center" background="azul.jpg">
  67. <BR>
  68. <TR>
  69.  
  70.   <td colspan="2" style="font-weight:bold"  ><span class="Estilo1"><center><font color="#FFFFFF"><h2>Acceso al Sistema</span></td>
  71.       </tr>
  72.  
  73. <TR><TR>
  74.   <TD colspan="2">&nbsp;</TD>
  75. </TR>
  76.   <TD><font color="#333333"><b>&nbsp;<font color="#000000">Nivel</b></font></TD>
  77.   <TD><font color="#333333">&nbsp;
  78.     <SELECT name="nivel">
  79.       <option value="001">Administrador</option>
  80.       <option value="002">Docente</option>
  81.       <option value="003">Alumno</option>
  82.     </SELECT>
  83.  
  84.   </font></TD>
  85. </TR>
  86. <TR>
  87.   <TD ><font color="#333333">&nbsp;<font color="#000000">Usuario</font></TD>
  88.   <TD><font color="#333333">&nbsp;
  89.     <INPUT type="text" name="txtusuario" size="20" maxlength="20">
  90.   </font></TD>
  91. </TR>
  92. <TR>
  93.   <TD ><font color="#333333">&nbsp;<font color="#000000">Contrase&ntilde;a</font></TD>
  94.   <TD><font color="#333333">&nbsp;
  95.     <INPUT type="password" name="txtcontrasena" size="20" maxlength="20">
  96.   </font></TD>
  97. </TR>
  98. <TR>
  99.   <TD colspan="2"><font color="#333333">&nbsp;</font></TD>
  100. </TR>
  101. <TR>
  102.   <TD colspan="2" align="center">&nbsp;<INPUT type="submit" name="aceptar" value="Aceptar"></TD>
  103. </TR> </tr>
  104.       </table></td>
  105.       <td width="400" bgcolor="#006633"><div align="center">
  106.          
  107.         <p><img src="texasteach_kids.jpg" width="400" height="200" /></p>
  108.        
  109.       </div></td>
  110.     </tr>
  111. </TABLE>
  112.  
  113. </form>
  114. </body>
  115. <br>
  116. <br>
  117. <font color="#FFFFFF">
  118. <center
  119. <p><img src="baner.jpg"/></p></center>
  120.  
  121.  
  122. </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
  1.         $vlogin=$row[1];
  2.         $claved=desencriptar($row[2]);
  3.         if($vlogin==$usu && $claved==$cla)
  4.         {
  5.         //   if($row[4]=='A')
  6.        //{
  7.              
  8.            header ("Location: administrador.php");
  9.            session_start();
  10.            $_SESSION['idusuario']=$row[0];

entrar.php


Código PHP:
Ver original
  1. <?php
  2. session_start();                   /* session_start debe ir antes de codigo     */
  3. //require_once("conexion.php");
  4. $nivel=$_POST['nivel'];
  5. $usu=$_POST['txtusuario'];
  6. $cla =($_POST['txtcontrasena']);
  7.     include("encriptar.php");
  8.     include("conexion.php");
  9. //**************** administrativo********************/
  10. if ($nivel=="001")
  11. {
  12.     $ssql="SELECT * FROM administrativo WHERE adm_apenom = '$usu'";
  13.     $rs = mysql_query($ssql,$conexion);
  14.      if (mysql_num_rows($rs)!=0)
  15.      {
  16.         $row=mysql_fetch_array($rs);
  17.         $vlogin=$row[1];
  18.         $claved=desencriptar($row[2]);
  19.         if($vlogin==$usu && $claved==$cla)
  20.         {
  21.         //   if($row[4]=='A')
  22.        //{
  23.              
  24.            header ("Location: administrador.php");
  25.            session_start();
  26.            $_SESSION['idusuario']=$row[0];
  27.  
  28.        }
  29.        else
  30.        {
  31.               header ("Location: index.php?errorInhabi=Usuario Inhabilitado!!");
  32.        }
  33.         }
  34.      else
  35.        {
  36.             header ("Location: index.php?error=Usuario no Existe!!");
  37.        }
  38.        mysql_free_result($rs);
  39.        mysql_close($conexion);
  40.        
  41. }      
  42.                
  43.                     //**************************************************docente
  44. if ($nivel=="002")
  45.     {
  46.     $ssql="SELECT * FROM docentes WHERE doc_apenom = '$usu'";
  47.     $rs = mysql_query($ssql,$conexion);
  48.      if (mysql_num_rows($rs)!=0)
  49.      {
  50.         $row=mysql_fetch_array($rs);
  51.         $vlogin=$row[1];
  52.         $claved=desencriptar($row[2]);
  53.         if($vlogin==$usu && $claved==$cla)
  54.         {
  55.         //   if($row[4]=='A')
  56.        //{
  57.              
  58.            header ("Location: docente.php");
  59.            session_start();
  60.            $_SESSION['idusuario']=$row[0];
  61.  
  62.        }
  63.        else
  64.        {
  65.               header ("Location: index.php?errorInhabi=Usuario Inhabilitado!!");
  66.        }
  67.         }
  68.      else
  69.        {
  70.             header ("Location: index.php?error=Usuario no Existe!!");
  71.        }
  72.        mysql_free_result($rs);
  73.        mysql_close($conexion);
  74.        
  75. }      
  76.                
  77. //**************************************************docente
  78. if ($nivel=="003")
  79. {
  80.     $ssql="SELECT * FROM alumnos WHERE      ALUCODIGO = '$usu'";
  81.     $rs = mysql_query($ssql,$conexion);
  82.      if (mysql_num_rows($rs)!=0)
  83.      {
  84.         $row=mysql_fetch_array($rs);
  85.         $vlogin=$row[0];
  86.         $claved=desencriptar($row[7]);
  87.         if($vlogin==$usu && $claved==$cla)
  88.         {
  89.         //   if($row[4]=='A')
  90.        //{
  91.              
  92.            header ("Location: alumno.php");
  93.            session_start();
  94.            $_SESSION['idusuario']=$row[0];
  95.  
  96.        }
  97.        else
  98.        {
  99.               header ("Location: index.php?errorInhabi=Usuario Inhabilitado!!");
  100.        }
  101.         }
  102.      else
  103.        {
  104.             header ("Location: index.php?error=Usuario no Existe!!");
  105.        }
  106.        mysql_free_result($rs);
  107.        mysql_close($conexion);
  108.        
  109. }      
  110.                
  111. $_SESSION['alumnos']=$_POST["txtusuario"];
  112. $_SESSION['contrasena']=$_POST["txtcontrasena"];
  113. //header("Location: guardaralumno.php");
  114.    
  115. //**********************************
  116. ?>
__________________

"Nuestra capacidad se aleja de la Humanidad"