PDA

View Full Version : Site Alert



Jamieb
11-11-2010, 11:26 PM
Hey just a quick one,

I am working on a site for a mate and he wants a site alert panel so I have served this forum and cant find one that works... can any one tell me where I can get one or help fix this one...

disp.php

<?php

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

session_start();
if(!isset($_SESSION['alert'])) {
$_SESSION['alert'] = 'no_message';
}

$handle = fopen('message.txt', 'r');
$message = fread($handle, filesize('message.php'));
fclose($handle);

if($message != $_SESSION['alert'] && $message != 'none') {
print '<script type="text/JavaScript">alert(\''.$message.'\');</script>';
$_SESSION['alert'] = $message;
}

?>

updatealert.php


<html>
<head>
<script>
function update() {
document.getElementById('display_alert').src = 'disp.php';
setTimeout('update()', 10000);
}
</script>
</head>
<body onLoad="update();">
<iframe id="display_alert" style="display: none" src="disp.php"></iframe>
</body>
</html>

Thanks +rep any one.

Want to hide these adverts? Register an account for free!