takeiteasy Posted May 10, 2006 Share Posted May 10, 2006 can i ask if there's php code for displaying an alert dialog box?if there is. can anyone teach me how to code please?i'm doing a delete function and i want to prompt the user if they really want to delete the record.here is my delete code [code]if (isset($HTTP_GET_VARS['empRef'])){$result = mysql_query("DELETE FROM airticketbooking WHERE empRef = '$empRef'",$db_connection) or die(mysql_error());mysql_close($db_connection);}if($result == true){ echo "'Record Deleted' ";}[/code] Quote Link to comment https://forums.phpfreaks.com/topic/9452-alert-dialog-box/ Share on other sites More sharing options...
wildteen88 Posted May 10, 2006 Share Posted May 10, 2006 There is no way to do it in PHP. But you can with javascript. What you'll want to do is sometying like this:Place this code just before the <head> tags on your script[code]<script type="text/javascript">function confirmDel(){ var del = confirm("Are you sure you wish to continue?\n\nClick Ok to continue"); if (del) { return true; } else { return false; }}</script>[/code]Now the link. The following will be what you link will look like:[code]<a href="delete.php?id=$id" onclick="return confirmDel()">Delete</a>[/code]Change where it says [i]delete.php?id=$id[/i] to where you actually send the user and dont forget to send the and id over the url so mysql deletes the correct data from mysql.NOte the what how the code works is the onclick attribute. Notice that is says [i]return conformDel[/i]. What that does is it will only go to the delete.php page if and onlu of the confirmDel function returns true, otherwise it will not go any where, and thats how you create simple confirm box. Quote Link to comment https://forums.phpfreaks.com/topic/9452-alert-dialog-box/#findComment-34875 Share on other sites More sharing options...
takeiteasy Posted May 11, 2006 Author Share Posted May 11, 2006 oh! thank you so much wildteen88!! This really helps me alot!! Quote Link to comment https://forums.phpfreaks.com/topic/9452-alert-dialog-box/#findComment-35141 Share on other sites More sharing options...
texhead Posted May 30, 2006 Share Posted May 30, 2006 wildteen88! I have been looking for this simple explanation for a week now, all the others did not get down to the basics.Thanks!!! Quote Link to comment https://forums.phpfreaks.com/topic/9452-alert-dialog-box/#findComment-40371 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.