Results 1 to 3 of 3

Thread: Easily updated message

  1. #1
    Join Date
    Sep 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Easily updated message

    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

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Code:
    <?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.
    Last edited by djr33; 09-17-2007 at 03:24 PM.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    Sep 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thank you for the quick reply djr33, this is very helpful.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •