What are the potential pitfalls of using register_globals in PHP and how can they be avoided?

Using register_globals in PHP can lead to security vulnerabilities such as injection attacks and variable overwriting. To avoid these pitfalls, it is recommended to disable register_globals in the PHP configuration and instead use superglobal arrays like $_GET, $_POST, and $_SESSION to access form data and user input.

// Disable register_globals in php.ini
// Use superglobal arrays to access form data and user input
$name = $_POST['name'];
$email = $_POST['email'];