Skip to main content
GameDev.net gamedev.net
🔒 Locked

[web] simple but trouble problem in php

Started by Jaguar_Lee Apr 19, 2005 at 10:40 PM 0 replies 800+ views
Original Post
Jaguar_Lee
Jaguar_Lee
if the user delete a data, i need a alert to remind him if he really want to delete it, if he choose "no", then keep the data. i know that in &#106avascript it is just a very simple thing, just using the "confirm".but i find it difficult to realize in php. how can i do it? i have some trouble to combine the &#106avascript and php.
Sander
Sander
If you are going for the &#106avascript popup then there's no need to check what button he entered:

if( confirm(...) ){  window.location = "http://url_to_site/delete.php?id=whatever";}


The URL goes to the php file that does the deleting. If the user hits "no" then the URL will not be loaded at all. OTOH, if you want to do this all in PHP (no script) then you need soething like this:

if( isset($_REQUEST['submit']) ){  if( isset($_REQUEST['confirm']) )  {    //delete the stuff  }  else  {    echo "Are you sure? cancel yes";  }  exit();}//output default page/form here

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.