Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @include 'connect.php';
- $errors = [];
- if (isset($_POST['submit'])) {
- $username = $_POST['username'];
- $email = $_POST['email'];
- $password = $_POST['pwd'];
- $hashedPassword = password_hash($password, PASSWORD_DEFAULT);
- // Validate other fields if needed
- // Check if user already exists
- $select = "SELECT * FROM login_data WHERE username = '$username'";
- $result = mysqli_query($conn, $select);
- if (mysqli_num_rows($result) > 0) {
- $errors[] = 'User already exists!';
- } else {
- // Insert user data into the database with hashed password
- $insert = "INSERT INTO login_data (username, email, password) VALUES ('$username', '$email', '$hashedPassword')";
- mysqli_query($conn, $insert);
- header('location: login.php'); // Redirect to login page after successful registration
- exit();
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement