How can the header(Location: "") function be used to redirect a user back to a specific page after login in PHP?

When a user logs in successfully, you can use the header(Location: "") function in PHP to redirect them back to a specific page. This is useful for creating a seamless user experience after login. By setting the Location header to the desired page URL, the browser will automatically redirect the user to that page.

// After successful login, redirect the user to the homepage
header("Location: index.php");
exit();