How can one handle account deactivation and reactivation in a PHP registration system effectively?

To handle account deactivation and reactivation effectively in a PHP registration system, you can add a column in the user database table to store the account status (active or inactive). When a user deactivates their account, update the status to inactive. To reactivate the account, update the status back to active.

// Deactivate account
$user_id = 1; // User ID of the account to deactivate
$status = 'inactive';

// Update user status to inactive
$sql = "UPDATE users SET status = :status WHERE id = :user_id";
$stmt = $pdo->prepare($sql);
$stmt->execute(['status' => $status, 'user_id' => $user_id]);

// Reactivate account
$user_id = 1; // User ID of the account to reactivate
$status = 'active';

// Update user status to active
$sql = "UPDATE users SET status = :status WHERE id = :user_id";
$stmt = $pdo->prepare($sql);
$stmt->execute(['status' => $status, 'user_id' => $user_id]);