how to refresh page one time only?
if i using <meta http-equiv=refresh content=\"0;URL=\".... it keep on refresh every according as what in the content was set.

wat i want is.. it only refresh one time only before the page was loaded.
can anybody help me? thanks :?:

Use an if statement that wont succeed after the reload. Alot of my code uses redirects with that but they all go to the same page. I just use a variable set that helps stop it from getting to the redirect the second time. But it's all up to how you want to do it.

also consider why is it doing the refresh. Is there another way other than the meta tag get it to go. When is it refreshing and why.

if you just want to make sure it automatically loads the newest copy of the page, eg do a auto-refresh you don't need to use a meta tag, try using a header function instead...

header('Cache-Control: no-store, no-cache, must-revalidate');

another option, using the meta tag:
replace
<meta http-equiv=refresh content=\"0;URL=\"....

with (assuming the page you want to reload is index.php)

if (!isset($_GET['reload'])) {
     echo '<meta http-equiv=Refresh content="0;url=index.php?reload=1">';
}

thanks paradox... busy with other works last few days... now back to my php. hm.. i've tried to code... but its displaying error 404 each time the refresh taken.
Anyway... thanks paradox.

Make sure you change the url (of code provided by paradox) to the page you are working on. I used the similar method on my site for two years now and no single problem found.

how to refresh page one time only?
if i using <meta http-equiv=refresh content=\"0;URL=\".... it keep on refresh every according as what in the content was set.

wat i want is.. it only refresh one time only before the page was loaded.
can anybody help me? thanks :?:

Hello everyone,

I searched on google to find out how can i refresh my page just one time like you asked, and.. i didn't find nothing useful. I mean, i think there was some script posted in javascript but i don't know how to work with javascript and didn't understand the code. After all i decided to find some solution on my own because it wat really urgent.

So, the solutions are about to change the meta value
<meta http-equiv="refresh"

content="<?php echo $time; ?>;url=carconfigurator.php" />

.

The first solution that i DON'T recomend you :))

$str='SELECT * FROM refresh WHERE ip="'.$_SERVER['REMOTE_ADDR'].'";';
    
    $result=mysqli_query($link, $str);
    
    if(mysqli_num_rows($result))
        {
            $r=mysqli_fetch_assoc($result);
            
            $dataModificarii=explode(' ', $r['dataAdaugarii']);
            
            $timp=explode(':',$dataModificarii[1]);
            $data=explode('-',$dataModificarii[0]);
            
            $dataAdaugarii=mktime($timp[0], $timp[1], $timp[2], $data[1], $data[2], $data[0]);

            $current=time();
            if($current<$dataAdaugarii+800)
                $time=900;                
            else
                if($current>$dataAdaugarii+800)
                    {
                        $time=1;
                        $str='DELETE FROM refresh WHERE ip="'.$_SERVER['REMOTE_ADDR'].'";';
                        mysqli_query($link, $str);
                    }
        }
    else
        {
            $time=1;
            $str='INSERT INTO refresh VALUES(null, "'.$_SERVER['REMOTE_ADDR'].'", "1", now())';
            mysqli_query($link, $str);
        }

this is used with a database as you noticed. yes is a lot of code just for a refresh is silly but when is a MUST you will love it as i did :) This solution suck considering my last solution.

the second choice and you need to know that you need COOKIES ENABLED, is sooo easy. i create this solution because i had some database bugs with first solution.

so, here is the code:

if(!isset($_COOKIE['car_configurator']))
        {
            $time=1;
            setcookie('car_configurator', 1);
        }
    else
        $time=900;

you need COOKIES ENABLED.

write me at ionutanin@gmail.com and let me know if my solutions helped you. cheers

Ionut - Romania

Edited 7 Years Ago by monstruo: n/a

This article has been dead for over six months. Start a new discussion instead.