Skip to content
Advertisement

PHP – Can’t log out and show alert message at the same time

I have a PHP login system where you can delete your account/profile if you’d like to. When the user clicks on the button I want them to be logged out, their account to be deleted and an alert message (JavaScript) saying that their account has been deleted. The problem is that the alert message doesn’t appear when I include the logout.php file. If I remove that line of code the alert message appears, but the user will still be logged in. How can I fix this?

Here is my code.

profile.php:

JavaScript

delete.php:

JavaScript

logout.php:

JavaScript

Advertisement

Answer

Add redirection along with the alert() in js rather than doing in php.

JavaScript

This will show alert then redirect to logout.php

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement