Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Closed Thread
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-02-2003, 03:20 PM   PM User | #1
Silver Sun
New Coder

 
Join Date: Sep 2002
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Silver Sun is an unknown quantity at this point
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
Silver Sun is offline  
Old 02-02-2003, 03:48 PM   PM User | #2
pb&j
Regular Coder

 
Join Date: Jun 2002
Location: Canada
Posts: 254
Thanks: 0
Thanked 0 Times in 0 Posts
pb&j is an unknown quantity at this point
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.";
}
?>
pb&j is offline  
Old 02-02-2003, 05:28 PM   PM User | #3
Spookster
Supreme Overlord


 
Spookster's Avatar
 
Join Date: May 2002
Location: Marion, IA USA
Posts: 6,224
Thanks: 4
Thanked 80 Times in 79 Posts
Spookster will become famous soon enough
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
Who gave you that Ugging infraction? Yeah that's right it was me!
Spookster is offline  
Closed Thread

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:25 AM.


Advertisement
Log in to turn off these ads.