This really isn't a question, but a coding example for other newbies, like myself.
PHP doesn't have any native Dialog Box control mechanism. Because of this, you might be tempted to rely on Javascript to handle it. Based on my conversations with people here, it wouldn't be a good idea, because Javascript can be disabled on a user's browser, effectively breaking your script.
An option would be to create your own dialog box using HTML <table> and <form> tags. I will provide an example below:
My page is called mypage.php. In my page, I might need a dialog box for flow control. It would look something like this:
<?php
// get a posted variable
$var1=$_POST['var1'];
// if the posted variable isn't there...
if ($var1=="")
{
// then draw up the dialog box
echo "
<table bgcolor='gray'>
<tr>
<td>
Do you want to continue?
</td>
</tr>
<tr>
<form method='post' action='mypage.php'>
<input type='hidden' name='var1' value='Yes sirree, Bob!'>
<td align='center'>
<input type='submit' value='Yes'>
</td>
</form>
<form method='post' action='mypage.php'>
<input type='hidden' name='var1' value='No way, Jose!'>
<td align='left'>
<input type='submit' value='No'>
</td>
</form>
</tr>
</table>
";
}
// otherwise, echo the set variable
else
{
echo "The variable set is: $var1";
}
?>
My experience has been that you need to put the <form> tags outside the <td> tags, otherwise it messes up your formatting. Also, I use "align" qualifiers in the <td> tags to line the buttons up better.
Using this method, you can create the equivalent of a Dialog Box, using server side PHP scripting. It isn't pretty, but it works. 🙂