menu_insert.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. /*
  3. * Inserta los datos de un nuevo Menú. El orden es por default al último
  4. * Recibe:
  5. * desc - Descripción del menú
  6. * mostrar - Si se muestra en la barra o no
  7. * icono - Icono de FA
  8. * Error:
  9. * 0 - No se recibieron los datos
  10. * 1 - Error de base de datos
  11. * Success:
  12. */
  13. require_once("../include/constantes.php");
  14. require_once("../include/bd_pdo.php");
  15. $pag = "../menus.php";
  16. //--- Objeto para validar usuario. El id de usuario lo lee desde sesión
  17. session_start();
  18. if(!$_SESSION["sgi_administrador"]){
  19. header("Location: main.php");
  20. exit();
  21. }
  22. unset($objValida);
  23. if(!isset($_POST["desc"]) || !isset($_POST["mostrar"], $_POST["sist"])){
  24. header("Location: ".$pag."?error=0");
  25. exit();
  26. }
  27. $desc = trim(filter_input(INPUT_POST, "desc", FILTER_SANITIZE_STRING,array('flags' => FILTER_FLAG_STRIP_LOW)));//limpia texto
  28. $sist = filter_input(INPUT_POST, "sist", FILTER_SANITIZE_NUMBER_INT);//limpia texto
  29. $mostrar = filter_input(INPUT_POST, "mostrar", FILTER_SANITIZE_NUMBER_INT);//limpia texto
  30. //$mostrar = ($mostrar == 0 ? false : true);
  31. $icono = trim(filter_input(INPUT_POST, "icono", FILTER_SANITIZE_STRING,array('flags' => FILTER_FLAG_STRIP_LOW)));//limpia texto
  32. $stmt = $pdo->prepare('Select * from fi_menu(:sist, :desc, :mostrar, :ico)');
  33. $stmt->bindParam(":sist", $sist);
  34. $stmt->bindParam(":desc", $desc);
  35. $stmt->bindParam(":mostrar", $mostrar);
  36. $stmt->bindParam(":ico", $icono);
  37. if(!$stmt->execute()){
  38. print_r($stmt->errorInfo());
  39. //header("Location:".$pag."?error=4&sist=".$sist);
  40. exit();
  41. }
  42. $rs = $stmt->fetch();
  43. $stmt->closeCursor();
  44. $stmt = null;
  45. header("Location: ".$pag."?ok=2&sist=".$sist);
  46. exit();
  47. ?>