Reputation: 378
Really quick question, how can I run a line of PHP code when an HTML button is pressed. What I am trying to do is destroy a php session (to log the user out) when the logout button is pressed.
Thanks!
Upvotes: 0
Views: 34
Reputation: 507
Basically you need to call js function which will be executed when you press the logout button. That will redirect user to logout url. and that url/script will destroy the session and redirect user to homepage.
Upvotes: 0
Reputation: 178
If you want to use the button, then you should send a form to specific URL address where the session will be destroyed. If you want to use a link instead of a button, then you can point a specific URL address where your session code will be destroyed. All depends on your application architecture. But in one word, you need to send HTTP request to a place where the session will be destroyed.
Upvotes: 1