PHP is executed first before JS, but is there an easy way to output a confirmation dialog (like Javascript confirmation) if the data is not empty like in this conditional PHP statement:
<?php
if (!empty($data)) {
//data is not empty
//Ideally I want to show a confirmation dialog in this part to the user
//to confirm if the user wants to overwrite the existing data
//If the user confirms
//Overwrite the existing data here
} else {
//data is empty,proceed to other task
//don't show any dialog
}
I don't want to add another form to the user, just a simple confirmation dialog like the JS confirm. Or is there a PHP replacement function for this? Thanks.