PageRenderTime 46ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/BD/sitio-atonaltzin/modificar_dueno.php

https://github.com/astrocumbia/UTM
PHP | 87 lines | 69 code | 14 blank | 4 comment | 10 complexity | c6f0b5144aa446707e9ef85a8bd8b8c1 MD5 | raw file
Possible License(s): GPL-2.0
  1. <?php
  2. @session_start();
  3. /* Verificar que el usuario inicio sesion */
  4. if(!isset($_SESSION['usuario']))
  5. {
  6. echo '<script> location.href = "login.php"; </script>';
  7. exit();
  8. }
  9. /* rechazar si el taquillero intenta entrar localhost/sitio/reportes.php */
  10. if( $_SESSION['puesto']=="Taquillero" ){
  11. echo '<script> location.href = "inicio.php"; </script>';
  12. exit();
  13. }
  14. include("funciones.php");
  15. //print_r( $_POST );
  16. $nombre = $_POST['nombre'];
  17. $apellido = $_POST['apellido'];
  18. $ID = $_POST['ID'];
  19. if( $nombre == "" ){
  20. echo '
  21. <div class="alert alert-danger col-lg-offset-1 col-md-7">
  22. <span class="glyphicon glyphicon-remove-circle"></span>
  23. Ocurrio un error al agregar, el nombre estaba vacio.
  24. </div>
  25. ';
  26. return;
  27. }
  28. if( $apellido == "" ){
  29. echo '
  30. <div class="alert alert-danger col-lg-offset-1 col-md-7">
  31. <span class="glyphicon glyphicon-remove-circle"></span>
  32. Ocurrio un error al agregar, el usuario estaba vacio.
  33. </div>
  34. ';
  35. return;
  36. }
  37. $GLOBALS["CONEXION"] = mysql_connect( $GLOBALS["servidor"], $GLOBALS["usuario"], $GLOBALS["password"] ) or die(mysql_error() );
  38. mysql_select_db( $GLOBALS["basedatos"], $GLOBALS["CONEXION"] );
  39. /* valida que tengan diferente username */
  40. $myquery = "select * from DUENO where nombre like '$nombre' AND apellido like '$apellido' AND id_dueno=$ID;";
  41. $resultados = mysql_query( $myquery, $GLOBALS["CONEXION"]) or die ( mysql_error() );
  42. if( mysql_num_rows( $resultados ) != 1 ){
  43. $myquery = "select * from DUENO where nombre like '$nombre' AND apellido like '$apellido';";
  44. $resultados = mysql_query( $myquery, $GLOBALS["CONEXION"]) or die ( mysql_error() );
  45. if( mysql_num_rows( $resultados ) > 0 ){
  46. echo '
  47. <div class="alert alert-danger col-lg-offset-1 col-md-7">
  48. <span class="glyphicon glyphicon-remove-circle"></span>
  49. Ocurrio un error, el dueño '.$nombre.' '.$apellido.' esta en uso.
  50. </div>
  51. ';
  52. return;
  53. }
  54. }
  55. $myquery = "UPDATE DUENO SET nombre='$nombre', apellido='$apellido' WHERE id_dueno=$ID;";
  56. $resultados = mysql_query( $myquery, $GLOBALS["CONEXION"]) or die ( mysql_error() );
  57. if( mysql_query( $myquery, $GLOBALS["CONEXION"]) or die ( mysql_error() ) ){
  58. echo '
  59. <div class="alert alert-warning col-lg-offset-1 col-md-7">
  60. <span class="glyphicon glyphicon-warning-sign"></span>
  61. Se ha modificado el dueño '.$nombre.' '.$apellido.'.
  62. </div>
  63. ';
  64. }
  65. else{
  66. echo '
  67. <div class="alert alert-danger col-lg-offset-1 col-md-8">
  68. <span class="glyphicon glyphicon-remove-circle"></span>
  69. Ocurrio un error al modificar el dueño '.$nombre.' '.$apellido.', Contacte con servicio técnico.
  70. </div>
  71. ';
  72. }
  73. ?>