Page 2 of 2 FirstFirst 12
Results 11 to 12 of 12

Thread: Allow authorized user to change text on webpage *SOLVED* Please comment

  1. #11
    Join Date
    Jun 2007
    Posts
    543
    Thanks
    3
    Thanked 78 Times in 78 Posts
    Blog Entries
    1

    Default

    admin.php:
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    
    <head>
    <title></title>
    
    
    </head>
    
    <body>
    <?php 
    if ($_POST['password']=="your_pass" && $_POST['username']=="your_user") {
    ?>
    <h1>TICKER CHANGE PAGE</h1>
    
    <h2>60 Characters Maximum INCLUDING Spaces</h2>
    <br />
    <form action="process.php" method="post">
    Ticker Text: <input type="text" value="<?php include('ticker.txt');?>" size="60" maxlength="60" name="ticker_text" />
    <input type="submit" />
    </form>
    <?php
    } else {
    $error=(isset($_POST['submitted']) && $_POST['submitted']=="yes")?"Wrong username or password. Please try again.":"";
    echo '<span style="font-color:red">'.$error.'</span><br />';
    ?>
    <form method="post">
    Username: <input type="text" name="username" /><br />
    Password: <input type="text" name="password" />
    <input type="hidden" name="submitted" value="yes"/><br />
    <input type="submit" />
    </form>
    <?php
    }
    ?>
    </body>
    </html>
    process.php:
    Code:
    <?php
    
    $ticker_text = $_POST['ticker_text'];
    
    $ticker_file = "ticker.txt";
    $fh = fopen($ticker_file, 'w') or die("can't open file");
    fwrite($fh, $ticker_text);
    fclose($fh);
    echo $ticker_text;
    
    ?>
    and on any html page you want the ticker text: <?php include("ticker.txt");?> e.g:
    Code:
    <html>
    <head>
    </head>
    <body>
    <div id="ticker"><?php include("ticker.txt");?></div>
    </body>
    </html>
    [Jasme Library (Javascript Motion Effects)] My Site
    /\/\@ /\/\@|{
    There are 10 kinds of people in the world, those that understand binary and those that don't.

  2. #12
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,372
    Thanks
    77
    Thanked 3,421 Times in 3,382 Posts
    Blog Entries
    12

    Default

    This is an interesting thread, I'd just like to point out that the process php file should also be protected. htaccess could do that for the entire folder, making access to the form page protected as well. Or, at the very least, the login values should be passed forward to the process page along with the new text, where they would be validated again before any files are written to. Finally, if there's even just a chance more than one person would be writing to the file at the same time, it should be locked while doing so.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Similar Threads

  1. Comment Script with reply to comment support
    By luckycreationsindia in forum Looking for such a script or service
    Replies: 1
    Last Post: 01-17-2012, 08:29 PM
  2. user's simple entry onto a webpage?
    By HWL in forum Looking for such a script or service
    Replies: 25
    Last Post: 06-17-2010, 07:03 PM
  3. Resolved Change a webpage's background!
    By bruglione in forum Looking for such a script or service
    Replies: 18
    Last Post: 11-26-2008, 10:39 PM
  4. Certain Part of webpage change upon refresh?
    By stephenjames716 in forum HTML
    Replies: 4
    Last Post: 09-08-2008, 09:34 PM
  5. Replies: 0
    Last Post: 01-17-2007, 03:55 PM

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
  •