sistema_update.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. /*
  3. * Actualiza los datos del sistema
  4. * Recibe:
  5. * id - ID del menú a editar
  6. * desc - Descripción del menú
  7. * nombre
  8. * pagina base
  9. */
  10. require_once("../include/constantes.php");
  11. require_once("../include/bd_pdo.php");
  12. $pag = "../sistemas.php";
  13. session_start();
  14. //--- Valida que el usuaro tenga permisos de superadministrador
  15. if(!$_SESSION["sgi_administrador"]){
  16. header("Location: main.php");
  17. exit();
  18. }
  19. if(!isset($_POST["desc"]) || !isset($_POST["nombre"]) || !isset($_POST["pag"])){
  20. header("Location: ".$pag."?error=0");
  21. exit();
  22. }
  23. $id = filter_input(INPUT_POST, "id", FILTER_SANITIZE_NUMBER_INT);//limpia texto
  24. $desc = trim(filter_input(INPUT_POST, "desc", FILTER_SANITIZE_STRING,array('flags' => FILTER_FLAG_STRIP_LOW)));//limpia texto
  25. $nombre = trim(filter_input(INPUT_POST, "nombre", FILTER_SANITIZE_STRING,array('flags' => FILTER_FLAG_STRIP_LOW)));//limpia texto
  26. $pag_base = trim(filter_input(INPUT_POST, "pag", FILTER_SANITIZE_STRING,array('flags' => FILTER_FLAG_STRIP_LOW)));//limpia texto
  27. $stmt = $pdo->prepare('Select * from fu_sistema(:id, :nombre, :desc, :pag)');
  28. $stmt->bindParam(":id", $id);
  29. $stmt->bindParam(":nombre", $nombre);
  30. $stmt->bindParam(":desc", $desc);
  31. $stmt->bindParam(":pag", $pag_base);
  32. if(!$stmt->execute()){
  33. header("Location:".$pag."?error=2");
  34. exit();
  35. }
  36. $stmt->closeCursor();
  37. $stmt = null;
  38. header("Location: ".$pag."?ok=1");
  39. exit();
  40. ?>