sistema_delete.php 1003 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. /*
  3. * Borra un grupo
  4. * Recibe:
  5. * id - ID del sistema a borrar
  6. */
  7. require_once("../include/constantes.php");
  8. require_once("../include/bd_pdo.php");
  9. //--- Objeto para validar usuario. El id de usuario lo lee desde sesión
  10. session_start();
  11. //--- Valida que el usuaro tenga permisos de superadministrador
  12. if(!$_SESSION["sgi_administrador"]){
  13. header("Location: main.php");
  14. exit();
  15. }else if(!isset($_POST["id"])){
  16. $return["error"] = "Error! No se recibió la información de la carrera.";
  17. }else{
  18. $id = filter_input(INPUT_POST, "id", FILTER_SANITIZE_NUMBER_INT);//limpia texto
  19. $stmt = $pdo->prepare('Select * from fd_sistema(:id)');
  20. $stmt->bindParam(":id", $id);
  21. if(!$stmt->execute()){
  22. $return["error"] = "Ocurrió un error al borrar los datos del sistema";
  23. }else{
  24. $stmt->closeCursor();
  25. $stmt = null;
  26. $return["ok"] = "El sistema se borró con éxito.";
  27. }
  28. }
  29. $return["json"] = json_encode($return);
  30. echo json_encode($return);
  31. ?>