Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create confirm yes/no in php?

Tags:

php

message

I want to create a confirm yes/no box in php my code like this:

<?php
if(isset($_REQUEST['id']))
{
?>

<script>
 var cf=confirm("do you want to delete Y/N");
 if(cf)
  { i want to call code edit of php

  }
</script>
<?php
}
?>
<html>
<head>
</head>
<body>
<form name="frm" method="post" action="edit.php">
<a href="edit.php?id=1">Edit </a> <br>
<a href="edit.php?id=2">Edit </a> <br>
<a href="edit.php?id=3">Edit </a> <br>

</form>

</body>
</html>

I Want to when press Yes i call code edit in PHP But it do not work. Can you help me ? Thanks you

like image 346
Thanh Nguyen Avatar asked Dec 18 '22 17:12

Thanh Nguyen


1 Answers

Just use inline onclick event.

This is a simple techique, you can use it in your PHP page.

<a href="edit.php?id=1" onclick="return  confirm('do you want to delete Y/N')">Edit </a>
like image 80
Murad Hasan Avatar answered Jan 04 '23 16:01

Murad Hasan