How to Auto Refresh webpage every 5 seconds in PHP?

Below is a sample code demonstrating how to refresh the webpage automatically every 5 seconds in PHP.

How to Auto Refresh webpage every 5 seconds in PHP?

<?php

$url1=$_SERVER['REQUEST_URI'];

header("Refresh: 5; URL=$url1");

?>

4 Comments

  • i have problem FormValidator last click oclin button update but me click on button save update a gan it not validate

  • Hi i think i can use this for a problem i have….
    I need to find a way to get a page refresh IF a string is empty..
    LOGIC BELOW.
    IF $mystring = “” THEN ?

    How can i rewrite your code?

    Thanks for your time

  • if($mystring==””){
    $url1=$_SERVER[‘REQUEST_URI’];
    header(“Refresh: 5; URL=$url1”);
    }

    Try this bro. 🙂

    • Sure 🙂

Leave Your Comment