Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

126
Views
execute iplog.php on click of links

i am logging visitors IP by the following code below

$iplogfile = 'ips.txt';
    $ipaddress = $_SERVER['REMOTE_ADDR'];
        $webpage = $_SERVER['SCRIPT_NAME'];
            $timestamp = date('d/m/Y h:i:s');
            $browser = $_SERVER['HTTP_USER_AGENT'];
        $fp = fopen($iplogfile, 'a+');
        chmod($iplogfile, 0777);
    fwrite($fp, '['.$timestamp.']: '.$ipaddress.' '.$webpage.' '.$browser. "\r\n");
fclose($fp);

but i want it to be execute only when user clicks on this particular links

<a href="tel:+1 (000) 000-0000" class="btn-blue btn-red">Book Now</a>
<a href="tel:+1 (111) 111-1111" class="btn-blue btn-red">Call Now</a>

can someone help me out here? i cannot figure out how to acheive it :(

Thanks alot for your help and input.

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

In order to execute this on clicking particular links then you should follow one of the following ideas as example:

1- Query strings, You can add a URL query parameter so you can check if it exists or not using $_GET, If it exists you can call your code.

2- You can create a new PHP file, Let's name it (track.php), And let's use AJAX to send requests to track.php on clicking the links you define using a class as example.

3- You can check what is the current path and URL and to set conditions using STRPOS to define whether the URL has the page you need to run the function for or not.

about 4 years ago · Juan Pablo Isaza Report

0

You can call a function using onclick attribute in the HTML anghor tag. onclick="myFunction()"

<a onclick="myFunction()" href="tel:+1 (000) 000-0000" class="btn-blue btn-red">Book Now</a>
<a onclick="myFunction()" href="tel:+1 (111) 111-1111" class="btn-blue btn-red">Call Now</a>

<script type='text/javascript'>

function myFunction()
{
    // add your code here
}

</script>
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!