final60 Posted February 9, 2009 Share Posted February 9, 2009 Heya I would love to be able to have something where by users can paste their current status to be viewed by other users. To be more specific I would like a user to be able to input his/her name, level achieved and in which skill. So other users can find it easier to find hunting groups.(mmorpg related ). Preferably the data could be saved in a text file. Perhaps an input feild at the top of the block would look somethingn like: Name: [input field] Level: [input field] Skill: [input field] Send (button) Monje reached level 230 in Melee. Yakapo reached level 250 in Offensive Affliction. Jenny reached level 64 in Desert Forage. This could perhaps be used to great effect in a more general way to quickly check the status of forums users. Any help on this would be much appreciated! Quote Link to comment https://forums.phpfreaks.com/topic/144463-request-help-with-user-status/ Share on other sites More sharing options...
DeanWhitehouse Posted February 9, 2009 Share Posted February 9, 2009 Have you even tried this yourself? Show us how far you got and where you got stuck and we can help Quote Link to comment https://forums.phpfreaks.com/topic/144463-request-help-with-user-status/#findComment-758106 Share on other sites More sharing options...
final60 Posted February 9, 2009 Author Share Posted February 9, 2009 Im trying to get to grips with what i need. So far: formdata.txt where the 3 bits of data will be stored. formdata.php where the php code to append the data to the formdata.txt file and the form markup, with an iframe underneath the form displaying the contents of the formdata.txt file. <form enctype="multipart/form-data" action="uploader.php" method="POST"> <input type="text" size="5" name="user" value="User" /><input type="text" size="5" name="level" value="Level" /><input type="text" size="5" name="skill" value="Skill" /><input type="submit" value="Send" height="2" /> </form> <hr /> I have no idea where to start with the php code to apply the form data to the text file though . any help would be much appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/144463-request-help-with-user-status/#findComment-758137 Share on other sites More sharing options...
final60 Posted February 9, 2009 Author Share Posted February 9, 2009 Ive tried the folowing code in the formdata.php file: <?php $myFile = "formdata.txt"; $fh = fopen($myFile, 'a') or die("can't open file"); fwrite($fh, $_POST['user'],$_POST['level'],$_POST['skill']); fclose($fh); ?> I thought this would post the 3 bits of data in the form but im clearly missing something. Quote Link to comment https://forums.phpfreaks.com/topic/144463-request-help-with-user-status/#findComment-758157 Share on other sites More sharing options...
final60 Posted February 9, 2009 Author Share Posted February 9, 2009 Ive managed to come up with this: <html> <head> </head> <body> <form enctype="multipart/form-data" action="form.php" method="POST"> <input type="text" size="5" name="user" value="User" /><input type="text" size="5" name="level" value="Level" /><input type="text" size="5" name="skill" value="Skill" /><input type="submit" value="Send" height="2" /> </form> <hr /> <?php $myFile = "formdata.txt"; $fh = fopen($myFile, 'a') or die("can't open file"); fwrite($fh, $_POST['user']); $stringData = " reached level "; fwrite($fh, $stringData); fwrite($fh, $_POST['level']); $stringData = " in "; fwrite($fh, $stringData); fwrite($fh, $_POST['skill']); $stringData = ".<br />"; fwrite($fh, $stringData); fclose($fh); ?> <?php $myFile = "formdata.txt"; $fh = fopen($myFile, 'r'); $theData = fread($fh, 10000); fclose($fh); echo $theData; ?> </body> </head> It seems to work well for what i need, but can anyone help me with getting the latest submissions at the top, instead of at the bottom? Quote Link to comment https://forums.phpfreaks.com/topic/144463-request-help-with-user-status/#findComment-758217 Share on other sites More sharing options...
premiso Posted February 9, 2009 Share Posted February 9, 2009 If you use file to retrieve/display the file you can do an rsort on the array and it will reverse it so the top is displayed first. No need to rewrite the whole thing when you can simply re-organize it quick and easy. Assuming that the data is broken up by a line break ("\n"), that would work. If that is not an option, you will have to re-write the whole file each time a new entry is entered, which increases processing time quite a bit more and is more prone for collision errors due to the file having to be open for a bit longer. Quote Link to comment https://forums.phpfreaks.com/topic/144463-request-help-with-user-status/#findComment-758219 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.