Advertisement
Guest User

Untitled

a guest
Feb 10th, 2019
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. <?php
  2.  
  3. if(isset($_POST['submit'])) {
  4. $post_email = $_POST['email'];
  5. $post_password = $_POST['password'];
  6.  
  7. $servername = "localhost";
  8. $username = "root";
  9. $password = "";
  10. $database = "nasa";
  11.  
  12. // Create connection
  13. $conn = new mysqli($servername, $username, $password, $database);
  14.  
  15. // Check connection
  16. if ($conn->connect_error) {
  17. die("Connection failed: " . $conn->connect_error);
  18. }
  19. // echo "Connected successfully";
  20.  
  21. /* INSERT */
  22.  
  23. $sql = "INSERT INTO account (email, password)
  24. VALUES ('" . $post_email . "', '" . $post_password . "')";
  25.  
  26. if ($conn->query($sql) === TRUE) {
  27. // echo "New record created successfully";
  28. echo "<script>window.location.assign('index.php');</script>";
  29. } else {
  30. echo "Error: " . $sql . "<br>" . $conn->error;
  31. }
  32.  
  33. $conn->close();
  34. }
  35.  
  36. // echo 'Email: ' . $email;
  37. // echo 'Password: ' . $password;
  38.  
  39. ?>
  40.  
  41. <!DOCTYPE html>
  42. <html>
  43. <head>
  44. <title>Simple Connection</title>
  45. </head>
  46. <body>
  47. <form action="#" method="POST">
  48. <input type="email" name="email">
  49. <input type="password" name="password">
  50. <button type="submit" name="submit">Submit</button>
  51. </form>
  52. </body>
  53. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement