tarjeta_crear.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. /*
  3. * Asigna pareja a participantes activos
  4. */
  5. require_once("../../include/constantes.php");
  6. require_once("../../include/bd_pdo.php");
  7. session_start();
  8. if(!isset($_SESSION["n_usuario_id"])){
  9. session_destroy();
  10. $pag = "../salir.php?expired=1";
  11. header("Location: ".$pag);
  12. exit();
  13. }
  14. $session_life = 1*60*60;//convertido a segundos
  15. if (isset($_SESSION["n_timeout"])) {
  16. // calculate the session's "time to live"
  17. $sessionTTL = time() - $_SESSION["n_timeout"];
  18. if ($sessionTTL > $session_life) {
  19. $_SESSION = array();
  20. session_destroy();
  21. $pag = $_SERVER['SERVER_NAME']."/navidad/salir.php?expired=1";
  22. header("Location: http://".$pag);
  23. exit();
  24. }
  25. }else{
  26. $_SESSION = array();
  27. session_destroy();
  28. $pag = $_SERVER['SERVER_NAME']."/navidad/salir.php?expired=1";
  29. header("Location: http://".$pag);
  30. exit();
  31. }
  32. $_SESSION["n_timeout"] = time();
  33. $pag = "../tarjeta.php";
  34. if(!isset($_POST["texto"]) || trim($_POST["texto"]) == ""){
  35. header("Location: ".$pag."?error=0");
  36. exit();
  37. }
  38. //$texto = nl2br(trim(filter_input(INPUT_POST, "texto", FILTER_SANITIZE_SPECIAL_CHARS,array('flags' => FILTER_FLAG_STRIP_LOW))));//limpia texto
  39. $texto = nl2br(htmlentities(trim($_POST["texto"]), ENT_QUOTES, "UTF-8"));//limpia texto
  40. //actualiza
  41. $stmt = $pdo->prepare('Select * from fu_navidadtarjeta(:de, :texto)');
  42. $stmt->bindParam(":de", $_SESSION["n_usuario_id"]);
  43. $stmt->bindParam(":texto", $texto);
  44. if(!$stmt->execute()){
  45. header("Location: ".$pag."?error=1");
  46. exit();
  47. }
  48. $stmt->closeCursor();
  49. header("Location: ../main.php?ok=0");
  50. ?>