How can one ensure that a PHP script works with Register_Globals=Off?

When Register_Globals is set to Off, PHP does not automatically create global variables for form input data. To ensure that a PHP script works with Register_Globals=Off, you need to access form input data using the $_POST or $_GET superglobals instead of relying on automatically created global variables.

$username = isset($_POST['username']) ? $_POST['username'] : '';
$password = isset($_POST['password']) ? $_POST['password'] : '';

// Use the $username and $password variables in your script