iStriide Posted August 9, 2010 Share Posted August 9, 2010 I want it to the post to the page multiple times, instead of copying over the page. Help me with the code please: It's also a site view counter. <?php $count_my_page = ("practice2.php"); $hits = file($count_my_page); $hits[0] ++; $post = $_POST['message']; $fp = fopen($count_my_page , "w"); fputs($fp , "$hits[0]" . "$post"); fclose($fp); echo $hits[0] . "<br/>" . "$post"; ?> Quote Link to comment Share on other sites More sharing options...
gizmola Posted August 9, 2010 Share Posted August 9, 2010 Can you try and explain what your problem is? I don't understand your question. Quote Link to comment Share on other sites More sharing options...
iStriide Posted August 9, 2010 Author Share Posted August 9, 2010 Can you try and explain what your problem is? I don't understand your question. I'm going to have a textbox and a submit button, and every time I submit something I want it to post on the page, and stay their when I refresh it. Quote Link to comment Share on other sites More sharing options...
gizmola Posted August 9, 2010 Share Posted August 9, 2010 Ok, so open your output file for "Append". This will write the new entries at the bottom. Use a separate file for your counter for simplicity sake. I also noticed you pulled the code you have from a tutorial, but that tutorial doesn't even have valid PHP code in it. You might look at some of the other tutorials that offer a step by step hitcounter, however, a guest book and a hit counter are not the same thing. It sounds like you want a simple guestbook, and that's where you'll need the append, however, with guestbook entries you also need to have a format for the file, so that you can tell the entries apart when you're rendering them back out of the file. 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.