Log in

View Full Version : Easily updated message



jho
09-16-2007, 04:35 PM
Hello everyone,

I'm wondering if there is a program or script that will allow me to display a message on my web page that can be updated within seconds. Something that doesn't need me to go into my web site file manager to change.

I want a java chat on my site, but want a message at the top that I can change in seconds and one that doesn't scroll away when users type in messages ... so far I haven't found a chat that can do this so I'm seeing if it's possible to just do a small script above the chat instead.

Hopefully this all makes sense. Thank you for taking the time to read and respond.

Regards,
jho

djr33
09-16-2007, 09:19 PM
<?php
if (isset($_GET['update'])) {
$m = $_POST['message'];
if ($_POST['pass']=='mypasswordhere!') {
$f = fopen('message.txt','w+');
fwrite($f,$m);
fclose($f);
}
}
?>
//don't change above
//but change formatting below if you want
//and add proper formatting, like <html>, etc.
<form action="?update" method="post">
Password: <input type="password" name="pass"><br>
Message: <textarea name="message"><?php echo @$m; ?></textarea>
</form>

Then include the .txt file into your bar at the top--
<?php include('message.txt'); ?>

However, if you want it to load automatically--
1. Just refresh the page every 5 seconds, though this is kinda annoying.
2. Or, use AJAX to script it to check the message every few seconds then update if it's new.

jho
09-17-2007, 03:18 PM
Thank you for the quick reply djr33, this is very helpful.