Hello everyone !

How to make conditional messagebox in PHP?

How do I do it? Like for example, in deleting record inside the database. The user will be asked to input costumer_ID (there should be a button named "search") if the user pressed the button search, it will search through the database and if the record found, messagebox will appear "Delete this Record?" option will be "YES" and "NO". If the user choose "YES" record will be deleted. If the user choose "NO", it will load the page where the user asked to input costumer_ID.

Is there anyone who can help? PLEASE !!!

Thank's in advance.

Recommended Answers

All 7 Replies

You need a bit of javascript. You could escape out of php and just have the javascript but this example does it as an echo.

echo "
<script language=\"Javascript\">
<!--
var answer = confirm (\"Confirm the Delete of Record $ref_num\")
document.location.href='the_processing_program.php?other_parm=xxxxx&conf='+answer;
//-->
</script>
";

This passes the response to the alert box to the program that will process the delete / database update or whatever restricted operation you are using this to control.

Thanks for your reply crishea.

I try to use your code but it didn't work.

Is there any other way to do it? Just simple one. Thanks !

Member Avatar for P0lT10n

That is the only way to do that...

Member Avatar for P0lT10n

mark solved...

how can you call the variable answer inside that script?

in the_processing_program.php:
$answer=$_GET['conf']

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.