What best practices should be followed when uploading PHP scripts to a website?

When uploading PHP scripts to a website, it is important to ensure that the scripts are secure and follow best practices to prevent vulnerabilities such as SQL injection or cross-site scripting attacks. One way to do this is by sanitizing user input and using prepared statements when interacting with a database.

// Example of sanitizing user input
$username = htmlspecialchars($_POST['username']);
$password = htmlspecialchars($_POST['password']);

// Example of using prepared statements
$stmt = $pdo->prepare('SELECT * FROM users WHERE username = :username AND password = :password');
$stmt->execute(['username' => $username, 'password' => $password]);