Jump to content

[SOLVED] php verification alerts???


elmas156

Recommended Posts

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

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>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.