manouche Posted March 11, 2010 Share Posted March 11, 2010 I have a form that I use to query a mysql database. The resulting page 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 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 query variable to another page to re-run the query that was previously done. Some pointers would be most welcome. Here is the code in the second page that 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> Link to comment https://forums.phpfreaks.com/topic/194964-makind-modificationsdeletions-and-sending-back-to-results-page/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.