elmas156 Posted August 30, 2008 Share Posted August 30, 2008 Hey everyone, I've got a small problem that I'm needing some help with. What I have is a page that displays a list of vehicles for a user with a form that allows the user to edit or delete a vehicle from their account. I have everything working but the problem is, when testing the system I accidentally clicked on the delete button instead of the edit button. There was nothing I could do and the vehicle was deleted forever. I want to put some type of alert on the page that pops up when a user clicks on the delete button to ask if they are sure they want to delete that particular vehicle before actually deleting it and also giving them the option to cancel the action. Does anyone know how to do this or at least where I should look to find the answers I need? Thanks in advance for any help you can provide. Here's the code to the page that I have: <?php // TEST SECTION $result = mysql_query("SELECT year,make,model,lp FROM vehicles WHERE email = '$email'"); while( $row = mysql_fetch_array( $result ) ) { $lp = $row[ "lp" ]; echo "<p>"; echo $row[ "year" ] . " "; echo $row[ "make" ] . " "; echo $row[ "model" ] . " "; echo "<form action=\"editvehicle.php\" method=\"POST\">"; echo "<input name=\"lp\" type=\"hidden\" id=\"lp\" value=\"$lp\">"; echo "<input name=\"submit\" type=\"submit\" value=\"Edit Vehicle\">"; echo "</form>"; echo "<form action=\"deletevehicle.php\" method=\"POST\">"; echo "<input name=\"email\" type=\"hidden\" id=\"lp\" value=\"$email\">"; echo "<input name=\"lp\" type=\"hidden\" id=\"lp\" value=\"$lp\">"; echo "<input name=\"$lp\" type=\"submit\" value=\"Delete\">"; echo "</form>"; echo "</p>"; } echo "<p><form action=\"addvehicle.php\" method=\"POST\"></p>"; echo "<input name=\"email\" type=\"hidden\" id=\"email\" value=\"$email\">"; echo "<input name=\"submit\" type=\"submit\" value=\"Add A Vehicle?\">"; // END TEST SECTION ?> Link to comment https://forums.phpfreaks.com/topic/121950-solved-php-verification-alerts/ Share on other sites More sharing options...
JasonLewis Posted August 30, 2008 Share Posted August 30, 2008 JavaScript, for the PopUp box. <script language="javascript"> function areYouSure(){ var e = confirm("Are you sure you want to delete?"); if(e){ return true; }else{ return false; } } </script> <form action="next.php" method="post"> <input type="submit" name="delete" value="Delete" onclick="javascript: return areYouSure()"> </form> Link to comment https://forums.phpfreaks.com/topic/121950-solved-php-verification-alerts/#findComment-629473 Share on other sites More sharing options...
elmas156 Posted August 30, 2008 Author Share Posted August 30, 2008 awesome, it works perfectly. I figured there was a way to do it with javascript but wasn't sure how to do it. I thought there might be a way to do it with php too. Hey, thanks ProjectFear! Link to comment https://forums.phpfreaks.com/topic/121950-solved-php-verification-alerts/#findComment-629483 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.