unsubscribe.php 825 B

1234567891011121314151617181920212223242526
  1. <?php
  2. $db = new mysqli('localhost', 'especificosba', 'howdoiturnthison', 'mailing');
  3. if($db->connect_errno > 0){ die('Unable to connect to database [' . $db->connect_error . ']'); }
  4. $mail = $_GET['mail'];
  5. $hash = $_GET['hash'];
  6. $statement = $db->prepare("select 1 from mails_datos where mail=? and hash=? and error is null");
  7. $statement->bind_param("ss", $mail, $hash);
  8. $statement->execute();
  9. if (!$statement->fetch()) {
  10. echo "Este email ($mail) no esta actualmente suscripto a nuestra base";
  11. die();
  12. }
  13. $statement->close();
  14. $statement = $db->prepare("update mails_datos set error='unsuscribe' where mail=? and hash=?");
  15. $statement->bind_param("ss", $mail, $hash);
  16. if(!$statement->execute()){
  17. echo "Hubo un error desuscribiendolo de la base de datos";
  18. die();
  19. }
  20. echo "Desuscripto correctamente";
  21. ?>