Jump to content


Photo

Entrys being at the top..


  • Please log in to reply
3 replies to this topic

#1 zrweber

zrweber
  • Members
  • PipPip
  • Member
  • 22 posts

Posted 28 October 2006 - 08:30 PM

Ok I'm pretty new to PHP so I don't really know what to call everything.. But I'm using this code

chatterboxaction.php:
<?php
$filename = "chatterbox.php";
$theText = $_POST["theMessage"];
$break = "<br>";

$theText = stripslashes($theMessage);

$data = fopen($filename, "a");

fwrite($data,$theMessage);
fwrite($data,$break);
fwrite($data,$break);

fclose($data);

echo "Your comment has been added!";
?>

index.php:
<form method="post" action="chatterboxaction.php">
<b><font face="Arial" color="#FFFFFF" size="2">Chat:</font></b><br>
<textarea name="theMessage" cols="25" rows="5"></textarea> <br>
<input type="submit" value="Post">
</form>

And what it does is let's people like say something in the form then it will add it to the page "chatterbox.php" but it adds it to the very bottom. Is there a way where when people fill out the form it adds it to the very top of the page?

Sorry if this is confusing lol..
www.zrweber.com

#2 gmwebs

gmwebs
  • Members
  • PipPipPip
  • Advanced Member
  • 174 posts
  • LocationLondon

Posted 28 October 2006 - 09:36 PM

When you open the file using fopen() you need to specify whether it is opened for reading, writing, or both. But you can also specify whether the file pointer is at the beginning or the end of the file.

Try this...

<?php

$data = fopen($filename, "x"); //Notice I changed it from a to x

?>

[url=http://uk2.php.net/manual/en/function.fopen.php]fopen() reference[url]

#3 zrweber

zrweber
  • Members
  • PipPip
  • Member
  • 22 posts

Posted 29 October 2006 - 12:14 AM

Ok the X didn't work, I tried the other ones that start at the beginning and they would just overwrite the file.
www.zrweber.com

#4 zrweber

zrweber
  • Members
  • PipPip
  • Member
  • 22 posts

Posted 31 October 2006 - 05:55 PM

bump any help?
www.zrweber.com




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users