Guest User

Untitled

a guest
Jul 20th, 2018
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.13 KB | None | 0 0
  1. <?php
  2. include_once '../pruebas/conexion.php';
  3.  
  4. $sql_leer = 'SELECT id,usuario,apellidos,email FROM usuarios WHERE id';
  5.  
  6. $gsnet = $pdo->prepare($sql_leer);
  7. $gsnet->execute();
  8.  
  9. $resultado = $gsnet->fetchAll();
  10.  
  11.  
  12. ?>
  13. <form action="envio_alerta.php" method="POST">
  14. <p>Nombre</p>
  15. <select class="custom-select mr-sm-2" id="inlineFormCustomSelect">
  16. <option selected>Elige opción</option>
  17. <?php foreach ($resultado as $dato): ?>
  18. <option ><?php echo $dato['usuario']?></option>
  19. <?php endforeach ?>
  20. </select>
  21. <br>
  22. <br>
  23. <p>Apellidos</p>
  24. <select class="custom-select mr-sm-2" id="inlineFormCustomSelect">
  25. <option selected>Elige opción</option>
  26. <?php foreach ($resultado as $dato): ?>
  27. <option><?php echo $dato['apellidos']?></option>
  28. <?php endforeach ?>
  29. </select>
  30. <br>
  31. <br>
  32. <p>Email</p>
  33. <select name="email" name="id" class="custom-select mr-sm-2" id="inlineFormCustomSelect">
  34. <option selected>Elige opción</option>
  35. <?php foreach ($resultado as $dato): ?>
  36. <option value="<?php echo $dato['id']?>"><?php echo $dato['email']?></option>
  37. <?php endforeach ?>
  38. </select>
  39. <br>
  40. <br>
  41. <p>Texto</p>
  42. <div class="form-group z-depth-2">
  43.  
  44. <textarea name="alerta" class="form-control" id="exampleFormControlTextarea3" rows="7"></textarea>
  45. </div>
  46. </div>
  47.  
  48. <div class="text-center py-4 mt-3">
  49. <button class="btn btn-outline-warning waves-effect z-depth-3" type="submit">Enviar</button>
  50. </div>
  51. </form>
  52.  
  53. <?php session_start();
  54.  
  55. include_once '../pruebas/conexion.php';
  56.  
  57. $alerta = $_POST['alerta'];
  58. $id = $_POST['id'];
  59. $destino =$_POST['email'];
  60. $sql_editar = "UPDATE usuarios SET alerta='$alerta' WHERE id='$id'";
  61. $sentencia_editar = $pdo->prepare($sql_editar);
  62. $sentencia_editar->execute(array($alerta,$id));
  63.  
  64. $contenido= "nEmail: " . $email . "nAlerta: " . $alerta;
  65.  
  66. mail($destino, "Contacto", $contenido);
  67.  
  68. if (mail){
  69. echo "<script type='text/javascript'>alert('Tu mensaje ha sido enviado');</script>";
  70.  
  71. }
  72.  
  73.  
  74. header('Location: reportes_usuario.php');
Add Comment
Please, Sign In to add comment