TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
 
 
LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old 10-26-2009, 10:43 PM   #1 (permalink)
The Visitor
 
Join Date: Oct 2009
Posts: 3
Thanks: 0
gallienne09 is on a distinguished road
Default Make a txt file display in reverse

Can some one tell me how to reverse the text file so it displays what goes in last first.

Cheers in advance

here is the code:

<html>
<head>
<title>test Text</title>
</head>
<body>
<div style='overflow:auto; width:230px; height:500px; background-color:orange'>
<fieldset width="200">
<legend>
<b>Message Board:</b>
</legend>

<form method="POST" action="text.php" style="font-family:verdana; font-size:10pt">
Nickname:<br><input type="text" name="name" size="25"/><br>
Comment:<br><textarea name="comment" rows="4" cols="23">
</textarea><br>
<input type="submit" value="Submit" />
<input type="reset" value="Reset" />
</form>
</fieldset>

<?php
$date= date("d/m/y");
$name=$_POST['name'];
$comment=$_POST['comment'];

if ($comment != "" )
{
$myFile = "testFile.txt";
$fh = fopen($myFile, 'a') or die("can't open file");
$stringData = "<b>Posted: $date</b>\n<br>";
fwrite($fh, "$stringData");
$stringData = "\"$comment\"\n<br>";
fwrite($fh, "$stringData");
$stringData = "<b>By:$name</b>\n<hr>";
fwrite($fh, $stringData);
fclose($fh);
}

else
{
echo "<b style='color:red'>Please fill in all fields!</b>";
}
?>


<?php

$myFile = "testFile.txt";
$fh = fopen($myFile, 'r');
$theData = fread($fh, filesize($myFile));
fclose($fh);

echo "
<table border='0' width='210' align='center'>
<tr>
<td style='font-family:verdana; font-size:8pt'>
$theData
</td>
</tr>
</table>


";
?>
<?php


?>
</div>
</body>
</html>
gallienne09 is offline  
Reply With Quote
 



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
how do i display on a php file the content of a text document chikooo Absolute Beginners 13 01-29-2013 11:44 AM
Read Text File in Reverse buildakicker General 9 11-26-2008 06:43 PM
Make array with txt file content Peuplarchie Absolute Beginners 2 07-17-2008 06:27 PM
Echoing Text File Rows into Array Display... buildakicker General 11 02-04-2008 07:17 PM
Make Your Own PHP Flash Player Which You Can Pass a File Variable with Preview!!!! thegrayman Tips & Tricks 2 12-12-2007 12:44 AM


All times are GMT. The time now is 10:34 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design