...

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



Silver Sun
02-02-2003, 04:20 PM
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

pb&j
02-02-2003, 04:48 PM
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.";
}
?>

Spookster
02-02-2003, 06:28 PM
Well don't start a new topic for it. Hit the button that says "Post REPLY from your original thread:

http://codingforums.com/showthread.php?s=&threadid=14000

Closing this thread...



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum