If you did not get it yet, you never "call" any UI-related element on server side. You always do it on client side. Server side can only generate HTML text or part of it (or other resources) in HTTP response, but the UI itself always operates in the browser. What happens when the user do some action in browser, say, chooses Yes or No, depends on the purpose of handling this event. Sometimes everything happens on the client side. Everything else is performed through another HTTP request, always. This request could request the same or new URI, or send a request via a Web form (also with some or another URI called "action") or, importantly, Ajax HTTP requests. Assuming your "check the database" is performed on the server side (which is the most reasonable way), you need to generate another HTTP request in one of these ways.
So, we are getting back to client-side (!) UI and hence JavaScript. The simplest way to request confirmation is calling
confirm
:
var confirmation = confirm("Do you want to continue?");
if (confirmation) sendSomeHttpRequest();
The only problem, the dialog will show not "Yes"/"No", but "OK"/"Cancel" (the "if" branch with the call shown above will execute after the press on "OK"), which could be fine in most cases.
For more serious features and flexibility, you can use jQuery
Dialog
(highly recommended). You can see how it works here:
http://jqueryui.com/dialog[
^].
But I would add: requesting a user for something is usually
not the best design, by far. But suggesting the alternatives need going into much finer detail of the problem.
—SA