Ania2019

save.php

May 11th, 2019
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. if (isset($_POST['email']) && ($emailQuery->rowCount() === 0) ) {
  2. //zdefiniowanie zmiennej $email
  3. $email = filter_input(INPUT_POST, 'email', FILTER_VALIDATE_EMAIL);
  4.  
  5. //if email is not correct syntax
  6. if (empty($email)) {
  7.  
  8. //nie powiodlo sie echo $_POST['email']. "<br/>" .$email;
  9. $_SESSION['given_email'] = $_POST['email'];
  10. header('Location: index.php');
  11.  
  12. } else {
  13.  
  14.  
  15. //poprawny adres echo $_POST['email']. "<br/>" .$email;
  16. // input into DB
  17.  
  18. $query = $db->prepare('INSERT INTO users VALUES (NULL, :email)');
  19. $query->bindValue(':email', $email, PDO::PARAM_STR);
  20. $query->execute();
  21. }
  22.  
  23. } else {
  24.  
  25.  
  26. header('Location: index.php');
  27. exit();
  28. }
Advertisement
Add Comment
Please, Sign In to add comment