Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if(isset($_POST['submit'])) {
- $post_email = $_POST['email'];
- $post_password = $_POST['password'];
- $servername = "localhost";
- $username = "root";
- $password = "";
- $database = "nasa";
- // Create connection
- $conn = new mysqli($servername, $username, $password, $database);
- // Check connection
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- // echo "Connected successfully";
- /* INSERT */
- $sql = "INSERT INTO account (email, password)
- VALUES ('" . $post_email . "', '" . $post_password . "')";
- if ($conn->query($sql) === TRUE) {
- // echo "New record created successfully";
- echo "<script>window.location.assign('index.php');</script>";
- } else {
- echo "Error: " . $sql . "<br>" . $conn->error;
- }
- $conn->close();
- }
- // echo 'Email: ' . $email;
- // echo 'Password: ' . $password;
- ?>
- <!DOCTYPE html>
- <html>
- <head>
- <title>Simple Connection</title>
- </head>
- <body>
- <form action="#" method="POST">
- <input type="email" name="email">
- <input type="password" name="password">
- <button type="submit" name="submit">Submit</button>
- </form>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement