Is there a PHP version of JavaScript's confirm() function?
If not, what are my other options or how do I make something similar to the confirm()?
Because PHP is a server-side language (all the PHP code is executed on the server, and the output of the code is sent to the client), you'd have to make an HTML form with OK/Cancel buttons that would submit to your PHP page. Something like this:
confirm.php:
<p>Are you sure you want to do this?</p>
<form action="page2.php" method="post">
<input type="submit" name="ok" value="OK" />
<input type="submit" name="cancel" value="Cancel" />
</form>
page2.php:
<?php
if (isset($_POST['ok'])) {
// They pressed OK
}
if (isset($_POST['cancel'])) {
// They pressed Cancel
}
?>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With