sistema_insert.php 1.3 KB

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