Results 1 to 2 of 2

Thread: Click code PHP

  1. #1
    GpF is offline New Member: Posts Will Be Moderated
    Join Date
    Jan 2011
    Posts
    1

    Click code PHP

    Hi!

    Can anyone help me to change the php code.

    What is the correct code with full url in click line?

    <a href="?click=yes">clickMe</a>


    <?php
    if(!file_exists('counter.txt')){
    file_put_contents('counter.txt', '0');
    }
    if($_GET['click'] == 'yes'){
    file_put_contents('counter.txt', ((int) file_get_contents('counter.txt')) + 1);
    header('Location: ' . $_SERVER['SCRIPT_NAME']);
    die;
    }
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>counter example</title>
    </head>
    <body>
    <h1><?php echo file_get_contents('counter.txt'); ?></h1>


    <a href="?click=yes">clickMe</a>


    </body>
    </html>

  2. #2
    Join Date
    Jun 2007
    Posts
    295
    it would be the folder structure/file name you are on now. For example, this page's URL is:

    http://www.mysite.com/welcome/entertext.php

    Then the href for what you have would be:

    <a href="entertext.php?click=yes">

    or you could do
    <a href="/welcome/entertext.php?click=yes">

    or you could put in the entire website:
    <a href="http://www.mysite.com/welcome/entertext.php?click=yes">

Similar Threads

  1. Click Picture, Store Location, Place Flag Where Click Occurred
    By dustout in forum Client & Server Side Scripting (PHP, ASP, JavaScript)
    Replies: 0
    Last Post: 05 Jul 2010, 01:15 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •