How can automatic page refresh after login be implemented in PHP?
To implement automatic page refresh after login in PHP, you can use the header() function to redirect the user to a specific page after successful login. You can set a delay using the header() function along with the location header to achieve the automatic page refresh effect.
// Check if login is successful
if($login_successful){
// Redirect to dashboard page after 3 seconds
header("refresh:3;url=dashboard.php");
echo "Login successful. Redirecting to dashboard...";
exit;
} else {
echo "Invalid login credentials";
}
Keywords
Related Questions
- Are there specific best practices for ensuring consistent character encoding when passing data between JavaScript and PHP?
- What are the potential pitfalls when using regular expressions in PHP for string manipulation?
- How does the handling of metadata in PDO result sets contribute to memory consumption compared to mysqli?