How can PHP be used to create a user registration process with profile creation on a website?

To create a user registration process with profile creation on a website using PHP, you can start by creating a registration form with fields for username, email, password, etc. Upon form submission, validate the input data and store it in a database. Then, create a profile page where users can update their information.

<?php
// Check if the registration form is submitted
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    // Validate and sanitize input data
    $username = htmlspecialchars($_POST["username"]);
    $email = filter_var($_POST["email"], FILTER_VALIDATE_EMAIL);
    $password = password_hash($_POST["password"], PASSWORD_DEFAULT);

    // Store user data in the database
    // Connect to database and execute SQL query

    // Redirect user to profile page
    header("Location: profile.php");
    exit();
}
?>