What SQL commands are needed to store the selected category in the database during user registration?

When a user registers on a website, the selected category needs to be stored in the database for future reference. To achieve this, you can use SQL commands to insert the selected category into the database table that stores user information. This can be done by capturing the selected category value from the registration form and including it in the SQL query that inserts the user details into the database.

// Assuming $selectedCategory contains the selected category value from the registration form

// SQL query to insert user details along with selected category into the database
$sql = "INSERT INTO users (username, email, password, category) VALUES ('$username', '$email', '$password', '$selectedCategory')";

// Execute the SQL query
if(mysqli_query($conn, $sql)) {
    echo "User registered successfully with selected category stored in the database.";
} else {
    echo "Error: " . $sql . "<br>" . mysqli_error($conn);
}