menu_updateorden.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. /*
  3. * Actualiza el orden de un menú.
  4. * Recibe:
  5. * id - ID del menú a mover
  6. * orden - Nuevo orden del menu
  7. * Error:
  8. * 0 - No se recibieron los datos
  9. * 1 - Error en la base de datos
  10. * Success:
  11. */
  12. require_once("../include/constantes.php");
  13. require_once("../include/bd_pdo.php");
  14. $pag = "../menus.php";
  15. //--- Objeto para validar usuario. El id de usuario lo lee desde sesión
  16. session_start();
  17. if(!$_SESSION["sgi_administrador"]){
  18. header("Location: main.php");
  19. exit();
  20. }
  21. if(!isset($_POST["id"]) || !isset($_POST["orden"]) || !isset($_POST["sist"])){
  22. header("Location: ".$pag."?error=0");
  23. exit();
  24. }
  25. $id = filter_input(INPUT_POST, "id", FILTER_SANITIZE_NUMBER_INT);//limpia texto
  26. $orden = filter_input(INPUT_POST, "orden", FILTER_SANITIZE_NUMBER_INT);//limpia texto
  27. $sist = filter_input(INPUT_POST, "sist", FILTER_SANITIZE_NUMBER_INT);//limpia texto
  28. $stmt = $pdo->prepare('Select * from fu_menuorden(:id, :orden_new, :sist)');
  29. $stmt->bindParam(":id", $id);
  30. $stmt->bindParam(":orden_new", $orden);
  31. $stmt->bindParam(":sist", $sist);
  32. if(!$stmt->execute()){
  33. header("Location:".$pag."?error=1&sist=".$sist);
  34. exit();
  35. }
  36. $stmt->closeCursor();
  37. $stmt = null;
  38. header("Location: ".$pag."?ok=3&sist=".$sist);
  39. exit();
  40. ?>