Execute an if in php only after clicking the [duplicate]

1

I need to run an if in PHP only if there is a click button. If there is no click the if does not execute. I already imagine that I will need to interact with JavaScript with PHP, but ... I read several posts but I still can not do it.

Put simply, it would look something like this:

<a href="">Clique</a>

<?php 

if (Clique == true) {
    Execute isso;
}else{
    Não execute nada;
}
    
asked by anonymous 27.11.2017 / 13:14

1 answer

1

I believe you meant when clicking a specific button to accomplish something that is within the if in PHP.

Just pass a parameter in the URL of the specific button and do the verification.

<a href="url_pagina_destino?p=execute">Botão especifico</a>

<a href="url_pagina_destino">Botão qualquer</a>

<?php 

    if ($_GET['p'] == "execute") {
        echo "Executei isso";
    }else{
        //Não executei nada;
    }

?>
    
27.11.2017 / 14:06