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.. Link to comment https://forums.phpfreaks.com/topic/25430-entrys-being-at-the-top/ 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] Link to comment https://forums.phpfreaks.com/topic/25430-entrys-being-at-the-top/#findComment-116052 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. Link to comment https://forums.phpfreaks.com/topic/25430-entrys-being-at-the-top/#findComment-116100 Share on other sites More sharing options...
zrweber Posted October 31, 2006 Author Share Posted October 31, 2006 bump any help? Link to comment https://forums.phpfreaks.com/topic/25430-entrys-being-at-the-top/#findComment-117408 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.