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
- How can the error message "Warning: open(/tmp\sess_19f72ec423601a07a29c2172f2399c8d, O_RDWR) failed: m (2)" when trying to create a session with session_start() be resolved in PHP?
- What are the best practices for organizing and structuring PHP files in a large project to avoid redundancy?
- What are the advantages and disadvantages of using stream contexts in PHP for file downloads?