Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

123
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda