Guest User

Untitled

a guest
Jul 28th, 2020
13
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. <?php
  2.  
  3. // Подключение к БД
  4. $dbh = new PDO('mysql:host=localhost;dbname=testing', 'root', 'root');
  5.  
  6. if(isset($_POST['submit'])) {
  7.  
  8. $name = $_POST['name'];
  9. $email = $_POST['email'];
  10.  
  11. $data = [
  12. 'name' => $name,
  13. 'email' => $email,
  14. 'subscription_status' => '1',
  15. ];
  16.  
  17. $sql = "INSERT INTO users (name, email, subscription_status) VALUES (:name, :email, :subscription_status)";
  18. $stmt= $dbh->prepare($sql);
  19. $stmt->execute($data);
  20. header( 'Location: succes.php');
  21. } else {
  22. exit('Fuck you!');
  23. }
  24.  
  25. ?>
  26.  
  27. <!DOCTYPE html>
  28. <html lang="ru">
  29. <head>
  30. <meta charset="UTF-8">
  31. <title>Подписка на рассылку</title>
  32. <style>
  33. .container {
  34. width: 50%;
  35. border: 1px solid black;
  36. margin: 0 auto;
  37. }
  38. .form {
  39. width: 40%;
  40. margin: 0 auto;
  41. margin-top: 10%;
  42. margin-bottom: 10%;
  43. }
  44. form {
  45. padding: 5px;
  46. }
  47. input {
  48. padding: 10px;
  49. margin: 5px;
  50. }
  51. button {
  52. padding: 10px;
  53. margin: 5px;
  54. border: none;
  55. border-radius: 5px;
  56. }
  57. button:hover {
  58. cursor: pointer;
  59. }
  60. </style>
  61. </head>
  62. <body>
  63. <div class="container">
  64. <div class="form">
  65. <form method="POST">
  66. <input type="text" name="name" placeholder="Имя:"><br>
  67. <input type="text" name="email" placeholder="E-mail:"><br>
  68. <button type="submit" name="submit">Подписаться</button>
  69. </form>
  70. </div>
  71. </div>
  72. </body>
  73. </html>
Advertisement
Add Comment
Please, Sign In to add comment