I have a form (page1.php) that I use to query a mysql database. The resulting page (page2.php) has an option to modify one field using a drop-down menu and another option to delete entire records via checkboxes. This works fine. After submitting either a modification or deletion, the user is sent to another page (page3.php) that gives them some feedback like "Your records have been deleted", with a link back to the search page. I would like the user to be redirected to the previous results page, minus the records that have been deleted, or with the modifications that were made.
So, do I use sessions, or somehow pass a results variable to another page to display the previous results of the query. Some pointers would be most welcome.
Here is the code for page3.php does the actual deletions and modifications.
if($POST['Modify'])
{
foreach($POST['id'] as $id)
{
$sql1="UPDATE documents SET status='".$_POST["status".$id]."' WHERE id='".$id."'";
$result1=mysql_query($sql1);
}
}
if($result1)
{
echo "Your record(s) have been modified. <a href='NEWindexGOOD.php'>Search again</a>";
}
if($POST['delete'])
{
$checkbox = $POST['checkbox'];
for($i=0;$i<count($checkbox);$i++)
{
$del_id = $checkbox[$i];
$sql2 = "DELETE FROM documents WHERE id='$del_id'";
// echo $sql2;
$result2 = mysql_query($sql2);
}
}
if($result2)
{
?>
<html>
<head>
<title>Title</title>
</head>
<body>
<center><h2>Blah blah blah</h3>
<table align="center" width = 400>
<tr><td> Your record(s) have been deleted. <a href="NEWindexGOOD.php'>Search again</a></td></tr>
</table>
<?php
}
?>
</body>
</html>