zrweber Posted October 28, 2006 Share Posted October 28, 2006 Ok I'm pretty new to PHP so I don't really know what to call everything.. But I'm using this codechatterboxaction.php:[code]<?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!";?>[/code]index.php:[code]<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>[/code]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.. Quote Link to comment Share on other sites More sharing options...
gmwebs Posted October 28, 2006 Share Posted October 28, 2006 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...[code]<?php$data = fopen($filename, "x"); //Notice I changed it from a to x?>[/code][url=http://uk2.php.net/manual/en/function.fopen.php]fopen() reference[url] Quote Link to comment Share on other sites More sharing options...
zrweber Posted October 29, 2006 Author Share Posted October 29, 2006 Ok the X didn't work, I tried the other ones that start at the beginning and they would just overwrite the file. Quote Link to comment Share on other sites More sharing options...
zrweber Posted October 31, 2006 Author Share Posted October 31, 2006 bump any help? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.