Run an if in php only after a click on the button

Asked

Viewed 708 times

0

I need to run a if in PHP only if there is a click on the button. Not having a click the if does not execute. I imagine I will need to interact Javascript with PHP, but... I read several posts but I still can not do.

Simply put, it would be something like this:

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

<?php 

if (Clique == true) {
    Execute isso;
}else{
    Não execute nada;
}
  • The point is, and the rest of the script? It should run when? Where is this PHP code? In the same file as the button? What is this if will you do it? Is there a question [Dit] describing all this? By the way, if it’s new here, I recommend that you do the [tour] by the site.

  • Possible duplicate.

  • just use the onclick function

1 answer

1

I believe you meant by clicking a specific button perform something that is inside if in PHP.

Just pass a parameter in the URL of specific button and make the check.

<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;
    }

?>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.