Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Sep 2002
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Ok, here is a piece of code which relates to my last post about new posts on top.....

    here is the code......

    <?php
    $filename = " $username $passwrd .txt";

    if (file_exists($filename)) {

    $file="test.txt";
    $fp=fopen("$file", "a+");
    $date = date ("d / m / y");
    $old = fread ($fp,EOF);

    $write =stripslashes("$new $old");
    print " $old ";
    fputs($fp, "$write");
    fclose($fp);
    print "Your message has been posted correctly";
    include ("test.txt");
    } else {
    print "Incorrect Username or Password, return to the previous page and try again.";
    }
    ?>

    The $old is the stuff that is already inside the txt file. The $new is the stuff sent through by a form.

    I need $new to appear on top, with $old appearing below it.

    Thanks in advance

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Location
    Canada
    Posts
    253
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Would this work?

    <?php
    $filename = " $username $passwrd .txt";

    if (file_exists($filename)) {

    $file="test.txt";
    $fp=fopen("$file", "a+");
    $date = date ("d / m / y");
    $old = fread ($fp,EOF);

    $foo = $new . $old;
    $write =stripslashes("$foo");
    print " $old ";
    fputs($fp, "$write");
    fclose($fp);
    print "Your message has been posted correctly";
    include ("test.txt");
    } else {
    print "Incorrect Username or Password, return to the previous page and try again.";
    }
    ?>

  • #3
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,278
    Thanks
    4
    Thanked 83 Times in 82 Posts
    Well don't start a new topic for it. Hit the button that says "Post REPLY from your original thread:

    http://codingforums.com/showthread.p...threadid=14000

    Closing this thread...
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster


  •  

    Posting Permissions

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