Jump to content

Recommended Posts

 

some think like this

link.

 

<a href='http://page_one.php?page_name=page_one&page_number=1'>press me</a>

?page_name=page_one&page_number=1

 

<?php

$sql="update page_counter set page_number=page_number+{$_GET['page_number']} WHERE
page_name='{$_GET['page_name']}'";

?>

$file = "submitCount.txt";
if (!file_exists($file)) {
    $count = 0;
}else {
    $count = file_get_contents($file);
}

$fh = fopen($file, "w+");
fwrite($fh, ($count + 1));
fclose($fh);

 

Simple as that with a flat file housing the data. You will of course have to put that into an if to check if the form was submitted or not.

<?php
$file = "submitCount.txt";
$count = (file_exists($file))?file_get_contents($file):0;

if (isset($_POST['submit']) {
   $count++;

   $fh = fopen($file, "w+");
   fwrite($fh, $count);
   fclose($fh);
}
?>
Submit Count is now <?php echo $count; ?><br />
<form method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>">
    <input type="submit" name="submit" value="Submit!" />
</form>

 

Should add one each time that form is submitted and display the count.

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.