Guest User

Untitled

a guest
Jun 25th, 2018
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. <html>
  2. <head>
  3. <Title>Exemplo</Title>
  4. </head>
  5. <body>
  6. <form action="Conecta.php" methodh="POST">
  7. Nome<input type="text" name="nome"/>
  8. E-mail<input type="email" name="email"/>
  9. Data de nascimento<input type="text" name="data_nasc"/>
  10. <input type="submit" name="Enviar"/>
  11. </form>
  12. </body>
  13. </html>
  14.  
  15. <?php
  16. $servername = "localhost";
  17. $database = "Cadastro";
  18. $username = "Root";
  19. $password = "xxxxx";
  20.  
  21. // Create connection
  22. $conn = mysqli_connect($servername, $username, $password, $database);
  23. // Check connection
  24. if (!$conn) {
  25. die("Connection failed: " . mysqli_connect_error());
  26. }
  27. echo "Connected successfully";
  28.  
  29. // RECEBENDO OS DADOS PREENCHIDOS DO FORMULÁRIO !
  30.  
  31. $nome = $_POST ["nome"];
  32. $email = $_POST ["email"];
  33. $data_nasc = $_POST ["data_nasc"];
  34. $data = date("Y-m-d",strtotime(str_replace('/','-',$data)));
  35.  
  36. $newslleter = "INSERT INTO newslleter (nome,email,data_nasc) VALUES ('$nome','$email','$data_nasc')";
  37.  
  38. if (mysqli_query($conn, $newslleter)) {
  39. echo "New record created successfully";
  40. } else {
  41. echo "Error: " . $usuarios . "<br>" . mysqli_error($conn);
  42. }
  43.  
  44. mysqli_close($conn);
  45. ?>
Add Comment
Please, Sign In to add comment