Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <meta http-equiv="X-UA-Compatible" content="ie=edge">
- <title>Document</title>
- </head>
- <body>
- <h2>New users</h2>
- <form method="POST" action="index.php">
- <h4>First Name: <input type="text" name="fname"></h4>
- <h4>Last Name: <input type="text" name="lname"></h4>
- <h4>Email: <input type="email" name="email"></h4>
- <h4>Password: <input type="password" name="pwd"></h4>
- <button type="submit" name="submit" value="submit"> Register</button>
- </form>
- </body>
- </html>
- <?php
- $servername = "localhost";
- $username = "root";
- $password = "";
- $db = "libdb";
- $conn = new mysqli($servername, $username, $password, $db);
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- $fname = $_POST['fname'];
- $lname = $_POST['lname'];
- $email = $_POST['email'];
- $pwd = $_POST['pwd'];
- $sql = "INSERT INTO user_tbl (fname, lname, email, pswd) VALUES ('$fname', '$lname', '$email', '$pwd')";
- if ($conn->query($sql) === TRUE) {
- echo "You have successfully registered. You may use your credentials to login now.";
- } else {
- echo "Error: " . $sql . "<br>" . $conn->error;
- }
- $conn->close();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement