What are some alternative approaches to updating user information in a database without affecting the ID field?

When updating user information in a database, it is important to ensure that the ID field remains unchanged as it serves as a unique identifier for each user. One approach to updating user information without affecting the ID field is to use a form that only allows the user to modify their personal details such as name, email, or address, while keeping the ID field hidden and not editable. This way, the ID remains constant while allowing the user to update their information.

<?php
// Assuming $userID is the ID of the user being updated
// Connect to database
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "myDB";

$conn = new mysqli($servername, $username, $password, $dbname);

// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}

// Update user information
$name = $_POST['name'];
$email = $_POST['email'];
$address = $_POST['address'];

$sql = "UPDATE users SET name='$name', email='$email', address='$address' WHERE id='$userID'";

if ($conn->query($sql) === TRUE) {
    echo "Record updated successfully";
} else {
    echo "Error updating record: " . $conn->error;
}

$conn->close();
?>