Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <h1>Register</h1>
- <form action="register.php" method="post">
- Username: <input type="text" name="rusername" /><p>
- Password: <input type="password" name="rpassword" /><p>
- Confirm Password: <input type="password" name="confirmpwd" /><p>
- <input type="submit" name="submit" value="Register" />
- </form>
- </html>
- <?php
- ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL);
- session_start();
- $rusername = $_POST['rusername'];
- $rpassword = $_POST['rpassword'];
- $confirmpwd = $_POST['confirmpwd'];
- $servername = '127.0.0.1';
- $loginusername = '';
- $loginpassword = '';
- $dbname = '';
- if ($rusername && $rpassword && $confirmpwd) {
- if ($rpassword == $confirmpwd) {
- $connect = new mysqli($servername, $loginusername, $loginpassword, $dbname);
- if ($connect->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- $query = "INSERT INTO user (id, username, email, password) VALUES (NULL, ?, NULL, ?)";
- $stmt = $connect->prepare($query);
- $stmt->bind_param("ss", $rusername, $rpassword);
- $stmt->execute();
- $stmt->close();
- $connect->close();
- } else {
- echo "Confirm password did not match...";
- }
- } else {
- echo "Please fill in all the fields...";
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement