How to create a confirmation window on a system in PHP?

0

I am a beginner in programming and I am creating a small system and in it I will have a button to move the user, the code:

<a href="../controller/controller.deslogar.php" title="Deslogar"><img src="img/logout.png" class="icon2"></a>

As you may have noticed, by clicking on the image, the user is automatically logged out, but I would like to put a confirmation window before deleting the user, because sometimes he may accidentally click. I would like in the confirmation window to have 2 buttons, "OK" and "Cancel", if the user clicked the "OK" button, it would be unlogged, if he clicked "Cancel", it would just close the confirmation window.

I searched the internet, but I did not find exactly what I wanted and as I am a beginner, I can not create 0 from this.

Thank you!

    
asked by anonymous 01.06.2017 / 17:10

2 answers

1

Is this what you want?

<a href="../controller/controller.deslogar.php" onclick="return confirm(Quer deslogar?');" title="Deslogar"><img src="img/logout.png" class="icon2"></a>

It can also be done as follows:

var logout = confirm("Quer fazer logout?");

if(logout){
     location.href = "../controller/controller.deslogar.php";
}
    
01.06.2017 / 17:26
0

Try using JQuery:

$('a[title="Deslogar"]').click(function(){
    confirm('Quer fazer logout?');
});
    
01.06.2017 / 18:54