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
https://forums.phpfreaks.com/topic/210263-php-postin/
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
https://forums.phpfreaks.com/topic/210263-php-postin/#findComment-1097243
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.