Advertisement
Guest User

Untitled

a guest
Oct 2nd, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.07 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Teste para estágio - Tmontec</title>
  6. <link rel="stylesheet" href="css/style.css">
  7. </head>
  8. <body>
  9. <h1>Tmontec</h1>
  10. <form action="" method="post" >
  11. <div class="form-control">
  12. <label for="nome">Nome:</label>
  13. <input type="text" id="nome" name="nome">
  14. </div>
  15. <div class="form-control">
  16. <label for="email">Email:</label>
  17. <input type="email" id="email">
  18. </div>
  19. <div class="form-control">
  20. <label for="telefone">Telefone:</label>
  21. <input type="text" id="telefone">
  22. </div>
  23. <div class="form-control">
  24. <label for="celular">Celular:</label>
  25. <input type="text" id="celular">
  26. </div>
  27. <div class="form-control">
  28. <label for="assunto">Assunto:</label>
  29. <input type="text" id="assunto" name="assunto">
  30. </div>
  31. <div class="form-control">
  32. <label for="mensagem">Redação:</label>
  33. <textarea name="" id="redacao" cols="30" rows="10"></textarea>
  34. </div>
  35. <div class="form-control">
  36. <button type="button">Enviar</button>
  37. </div>
  38.  
  39. <div class="form-control">
  40. <input type="reset" value="Limpar">
  41. </div>
  42. </form>
  43.  
  44. <script src="js/script.js"></script>
  45. </body>
  46. </html>
  47.  
  48.  
  49.  
  50. <?php
  51.  
  52. $host = "localhost";
  53. $user = "root";
  54. $pass = "";
  55. $database = ""
  56. $data = array_map('trim', $_REQUEST);
  57.  
  58. try {
  59. $conn = new PDO("mysql:host=$host;dbname=cubo_estagio", $user, $pass);
  60. // set the PDO error mode to exception
  61. $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  62. return "Formulário salvo com sucesso";
  63. $stmt = $conn->prepare('INSERT INTO teste(nome, email, telefone, celular, assunto, redacao) VALUES(:nome, :email, :telefone, :celular, :assunto ,:redacao)');
  64. $stmt->bindValue(':id', 1);
  65. $stmt->execute();
  66. ));
  67.  
  68. if($stmt->rowCount() > 0){
  69. return "Formulário salvo com sucesso";
  70. }
  71.  
  72. }
  73. catch(PDOException $e)
  74. {
  75. echo "Connection failed: " . $e->getMessage();
  76. }
  77. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement