robert_gsfame Posted June 23, 2010 Share Posted June 23, 2010 How can i pass the value $_POST after executing a query and redirect it using header() Assume: <?php $id=$_POST['id']; $deletequery=mysql_query(sprintf("DELETE FROM table1 WHERE id='%s'", mysql_real_escape_string($id))); if($deletequery) { header("Location:index.php"); } ?> is it possible to get the $_POST['id'] value in index.php thx Link to comment https://forums.phpfreaks.com/topic/205614-_post-and-header/ Share on other sites More sharing options...
Ruzzas Posted June 23, 2010 Share Posted June 23, 2010 <input type="hidden" name="id" value="<?php echo $_POST['id']; ?>"/> Put that code into that file and it should work Link to comment https://forums.phpfreaks.com/topic/205614-_post-and-header/#findComment-1075975 Share on other sites More sharing options...
TapeGun007 Posted June 23, 2010 Share Posted June 23, 2010 Why would a hidden form tag work on a redirect? I don't understand that. I can see using a header redirect and passing along information like: header("Location:index.php?ID=<value>"); But without someone clicking on a submit button, how would this post? Link to comment https://forums.phpfreaks.com/topic/205614-_post-and-header/#findComment-1075976 Share on other sites More sharing options...
Ruzzas Posted June 23, 2010 Share Posted June 23, 2010 Why would a hidden form tag work on a redirect? I don't understand that. I can see using a header redirect and passing along information like: header("Location:index.php?ID=<value>"); But without someone clicking on a submit button, how would this post? Yeah he's right... It won't work my bad You need to use Cookies, Session or $_GET[''] good luck! Link to comment https://forums.phpfreaks.com/topic/205614-_post-and-header/#findComment-1075978 Share on other sites More sharing options...
robert_gsfame Posted June 23, 2010 Author Share Posted June 23, 2010 if i dont want to use $_GET or cookies or Session can i still do this? Link to comment https://forums.phpfreaks.com/topic/205614-_post-and-header/#findComment-1075979 Share on other sites More sharing options...
Ruzzas Posted June 23, 2010 Share Posted June 23, 2010 if i dont want to use $_GET or cookies or Session can i still do this? Sorry but no... Link to comment https://forums.phpfreaks.com/topic/205614-_post-and-header/#findComment-1075980 Share on other sites More sharing options...
robert_gsfame Posted June 23, 2010 Author Share Posted June 23, 2010 okay thx a lot! Link to comment https://forums.phpfreaks.com/topic/205614-_post-and-header/#findComment-1075981 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.