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 Quote 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 Quote 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? Quote 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! Quote 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? Quote 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... Quote 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! Quote Link to comment https://forums.phpfreaks.com/topic/205614-_post-and-header/#findComment-1075981 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.