I have the following line of code:
echo '<INPUT TYPE="submit" name="delete" value="Delete account" onClick="return confirm('Are you sure you want to delete this account?')">';
How would I be able to determine whether the user entered yes or no?
PHP is server-side it doesn’t do anything on the client. A click is on the client, so PHP can’t handle this.
An onclick event is JavaScript, which is on the client-side. Read more about the onclick event in the Mozilla Docs.
The
confirm()returns aboolean, true or false.truewhen the user clicks ‘Yes’,falsewhen the users clicks on ‘No’.If you want to send the
booleanto PHP you need to use AJAX requests, but I don’t think you want it because you want to stop the submitting of the form.