Hello!
I have a small problem with a MySQL query inside a PHP site. If a user clicks "Yes" to delete a record, the record should be deleted (which works great)
However, when the user clicks "No", it should redirect the user to another location, leaving the record intact...but it redirects the user AND deletes the record anyway.
What am I overlooking?
Thank you in advance for any assistance!!
- Jim
require_once('mysql_connect.php');
if(isset($_POST['submitted'])){
if($_POST['sure'] == "Yes") {
echo $_POST['submitted'];
$query = "delete from movie_users where movie_users_id = '$id'";
$result = @mysql_query ($query);
header("Location: current_users.php");
echo "User deleted successfully";
} elseif($_POST['sure'] == "No") {
header("Location: not_deleted.php");
}
}
?>
<body>
<form action="delete_user.php" method ="post">
<div id="main">
<p><?PHP echo "Are you sure you want to delete user $fl_name"; ?>
</p>
<input type = "radio" name = "sure" value = "Yes" /> Yes
<input type = "radio" name = "sure" value = "No" /> No</p>
<p><input type = "submit" name = "submit" value = "submit" /> </p>
<input type = "hidden" name = "submitted" value = "TRUE" />
<input type = "hidden" name = "id" value = "<?php echo $id; ?>" />
</form>
</body>
</div>
mysql_close();
<?php
include('footer.php');
?>