Jump to content

[SOLVED] Refresh count HELP


SilentQ-noob-

Recommended Posts

Hi,

 

I want to make an if statement that counts how many times a page has been refreshed, and every ten times it refreshes I want it to do something. (send an e-mail for example)

I'm not sure if I have to use sessions or how to even go about it. I figured out how to make the page refresh every ten seconds, now I just need it to count that .

basically this is all I need to be displayed

 

Number of times page has refreshed: n

 

here is a link to a page that kind of has what I'm looking for, I just dont know how to change it to what I want.

 

http://www.dynamicdrive.com/forums/a...p/t-20513.html

 

That link doesnt seem to work- this is what it says there

<?php
session_start();
$mypage = 'index.php';
if (!isset($_SESSION['refresher'])) {
$_SESSION['refresher'] = 10;
}
elseif ($_SESSION['refresher'] <= 0) {
$_SESSION['refresher'] = 10;
header("location:$mypage");
}
else {
$_SESSION['refresher']--;
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="refresh" content="10">
<title>Refresher</title>
</head>

<body>
<p><?php echo $_SESSION['refresher']+1; ?> times until redirection.</p>
</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/64300-solved-refresh-count-help/
Share on other sites

ok, well I've figured out part of it now- Now the only thing that isnt working is the email part. The message gets sent, but it doesnt display the date, it just says "The Check was performed on      "

this is the code I have

<?
session_start();
if (!isset($_SESSION['refresh']))
$_SESSION['refresh']=0;
$_SESSION['refresh']++;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="refresh" content="2" />
<title>Untitled Document</title>
</head>

<body>
<?
$to = "[email protected]";
$subject= "System is Working";
$date = $_POST['date'];
print date("F d, Y g:iA");
print "<br />";
print "<br />";
echo "Number of times refreshed: "; echo $_SESSION['refresh'];
if($_SESSION['refresh'] == 10) {
session_destroy();
mail($to, $subject  ,"The Check was performed on $date");
}

?>

<p>

</body>
</html>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.