Jump to content

PHP Postin


iStriide

Recommended Posts

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";
?>

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.