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

Acabo de solucionarlo :
index.php

Código PHP:
Ver original
  1. <html>
  2. <head>
  3. <body bgcolor="#8A0808">
  4. <title>Autentificaci&oacute;n</title>
  5. </head>
  6. <font color="#3B0B0B"><center><h1><i>SISTEMA DE CONTROL DE MATR&Iacute;CULAS</i></h1></center></font>
  7. <form action="control.php" method="POST">
  8. <table align="center">
  9. <img src="imagenes/logo.png">
  10. </table>
  11. <br><br><br>
  12. <table border="1" align="center" cellpadding="1" cellspacing="1" bgcolor="Orange" width="25%">
  13. <tr>
  14. <td colspan="2" align="center">
  15. <?php
  16. if (@$_GET["errorusuario"]=="si"){
  17. ?>
  18. <font bgcolor=red><span style="color:red"><b><h3>DATOS INCORRECTOS</h3></b></span>
  19. <?php
  20. }
  21. else{
  22. ?>
  23. <bgcolor="black"><h3>INTRODUCE USUARIO Y CONTRASE&Ntilde;A</h3>
  24. <?php
  25. }
  26. ?></td>
  27. </tr>
  28. <tr>
  29. <td >NIVEL:</td>
  30.     <td><select name="nivel">
  31.       <option value="administrativo"> Administrativo</option>
  32.       <option value="docente">Docente</option>
  33.       <option value="alumno">Alumno</option>
  34.      
  35.     </select></td>
  36. </tr>
  37. <tr>
  38. <td>USUARIO:</td>
  39. <td><input type="Text" name="codigo" size="14" maxlength="10"></td>
  40. </tr>
  41. <tr>
  42. <td>CONTRASE&Ntilde;A :</td>
  43. <td><input type="password" name="contrasena" size="14" maxlength="10"></td>
  44. </tr>
  45. <tr>
  46. <td colspan="2" align="center"><input type="Submit" value="ACEPTAR"> <input type="reset" value="LIMPIAR"></td>
  47. </tr>
  48. </table>
  49. </form>
  50. </body>
  51. </html>


control.php

Código PHP:
Ver original
  1. <?php
  2. $conn = mysql_connect("localhost","root","");
  3. mysql_select_db("bdmatriculas",$conn);
  4. $nivel=$_POST['nivel'];
  5. $codigo=$_POST['codigo'];
  6. $contrasena=$_POST['contrasena'];
  7. if ($nivel=="alumno")
  8. {
  9. $ssql = "SELECT * FROM alumnos WHERE ALUCODIGO='$codigo' and aluclave='$contrasena'";
  10. $rs = mysql_query($ssql,$conn);
  11. if (mysql_num_rows($rs)!=0)
  12. {
  13.     session_start();
  14.     session_register("autentificado");
  15.     $autentificado = "SI";
  16.     header ("Location: alumno.php");
  17. }else
  18. {
  19.     header("Location: index.php?errorusuario=si");
  20. }
  21. mysql_close($conn);
  22. }
  23. if ($nivel=="docente")
  24. {
  25. $ssql = "SELECT * FROM docentes WHERE doc_codigo ='$codigo' and doc_clave='$contrasena'";
  26. $rs = mysql_query($ssql,$conn);
  27. if (mysql_num_rows($rs)!=0)
  28. {
  29.     session_start();
  30.     session_register("autentificado");
  31.     $autentificado = "SI";
  32.     header ("Location: administrador.php");
  33. }else
  34. {
  35.     header("Location: index.php?errorusuario=si");
  36. }
  37. mysql_close($conn);
  38. }
  39. if ($nivel=="administrativo")
  40. {
  41. $ssql = "SELECT * FROM administrativo WHERE adm_codigo ='$codigo' and adm_clave='$contrasena'";
  42.  
  43. $rs = mysql_query($ssql,$conn);
  44. if (mysql_num_rows($rs)!=0)
  45. {
  46.     session_start();
  47.     session_register("autentificado");
  48.     $autentificado = "SI";
  49.     header ("Location: administrador.php");
  50. }else
  51. {
  52.     header("Location: index.php?errorusuario=si");
  53. }
  54. mysql_close($conn);
  55. }
  56.  
  57. ?>
  58. <?php
  59. $conn = mysql_connect("localhost","root","");
  60. mysql_select_db("bdmatriculas",$conn);
  61. $nivel=$_POST['nivel'];
  62. $codigo=$_POST['codigo'];
  63. $contrasena=$_POST['contrasena'];
  64. if ($nivel=="alumno")
  65. {
  66. $ssql = "SELECT * FROM alumnos WHERE ALUCODIGO='$codigo' and aluclave='$contrasena'";
  67. $rs = mysql_query($ssql,$conn);
  68. if (mysql_num_rows($rs)!=0)
  69. {
  70.     session_start();
  71.     session_register("autentificado");
  72.     $autentificado = "SI";
  73.     header ("Location: alumno.php");
  74. }else
  75. {
  76.     header("Location: index.php?errorusuario=si");
  77. }
  78. mysql_close($conn);
  79. }
  80. if ($nivel=="docente")
  81. {
  82. $ssql = "SELECT * FROM docentes WHERE doc_codigo ='$codigo' and doc_clave='$contrasena'";
  83. $rs = mysql_query($ssql,$conn);
  84. if (mysql_num_rows($rs)!=0)
  85. {
  86.     session_start();
  87.     session_register("autentificado");
  88.     $autentificado = "SI";
  89.     header ("Location: administrador.php");
  90. }else
  91. {
  92.     header("Location: index.php?errorusuario=si");
  93. }
  94. mysql_close($conn);
  95. }
  96. if ($nivel=="administrativo")
  97. {
  98. $ssql = "SELECT * FROM administrativo WHERE adm_codigo ='$codigo' and adm_clave='$contrasena'";
  99.  
  100. $rs = mysql_query($ssql,$conn);
  101. if (mysql_num_rows($rs)!=0)
  102. {
  103.     session_start();
  104.     session_register("autentificado");
  105.     $autentificado = "SI";
  106.     header ("Location: administrador.php");
  107. }else
  108. {
  109.     header("Location: index.php?errorusuario=si");
  110. }
  111. mysql_close($conn);
  112. }
  113.  
  114. ?>


Les puede servir gracias de todas maneras Salu2.
__________________

"Nuestra capacidad se aleja de la Humanidad"