leonglass Posted October 1, 2007 Share Posted October 1, 2007 Is it possible to have a normal link, using anchor tags, and place a post var in it? Link to comment https://forums.phpfreaks.com/topic/71417-solved-post-variable-in-link/ Share on other sites More sharing options...
roopurt18 Posted October 1, 2007 Share Posted October 1, 2007 <?php $link = "<a href=\"http://www.home.com/delete={$_POST['somePostVar']}\">Delete</a>"; echo $link; ?> Link to comment https://forums.phpfreaks.com/topic/71417-solved-post-variable-in-link/#findComment-359479 Share on other sites More sharing options...
leonglass Posted October 1, 2007 Author Share Posted October 1, 2007 Thats great and so quick. I noticed that nothing past the "=" sign shows up when the link is hovered on. Is that linking to a page named delete. I tried it like this: <a href=\"http://localhost/forum/forum.php={$_POST['somePostVar']}\">Delete</a>" with and without the "=" and also removed the ".php" but no luck. Could you explain it a bit more for me please. Link to comment https://forums.phpfreaks.com/topic/71417-solved-post-variable-in-link/#findComment-359490 Share on other sites More sharing options...
roopurt18 Posted October 1, 2007 Share Posted October 1, 2007 Oops, I forgot the '?' that would indicate we're creating a get parameter. $link = "<a href=\"http://localhost/forum/forum.php?var={$_POST['somePostVar']}\">Delete</a>"; Of course for this to work there has to be a value inside of $_POST['somePostVar']. On the page in the link (forum.php in this case), to access the value you'd use: echo $_GET['var']; Link to comment https://forums.phpfreaks.com/topic/71417-solved-post-variable-in-link/#findComment-359511 Share on other sites More sharing options...
leonglass Posted October 2, 2007 Author Share Posted October 2, 2007 In which case that is not quite what I was after. I wanted to do it the other way around and put a value into $_POST within the link so that it is available on the linked page. Can that be done. Link to comment https://forums.phpfreaks.com/topic/71417-solved-post-variable-in-link/#findComment-359909 Share on other sites More sharing options...
roopurt18 Posted October 2, 2007 Share Posted October 2, 2007 $_POST variables are available from form posts. $_GET variables are available from the URL. So AFAIK you can't directly do it. You could place it in the URL and at the top of the script do: $_POST['someVar'] = $_GET['someVar']; and set the value manually if something in your script relies on it. Link to comment https://forums.phpfreaks.com/topic/71417-solved-post-variable-in-link/#findComment-360145 Share on other sites More sharing options...
MmmVomit Posted October 2, 2007 Share Posted October 2, 2007 I asked this quesion just yesterday. There's no direct way of doing it, but it's possible. http://www.phpfreaks.com/forums/index.php/topic,161623.0.html Link to comment https://forums.phpfreaks.com/topic/71417-solved-post-variable-in-link/#findComment-360156 Share on other sites More sharing options...
leonglass Posted October 2, 2007 Author Share Posted October 2, 2007 Thanks both I think I get the idea now. Link to comment https://forums.phpfreaks.com/topic/71417-solved-post-variable-in-link/#findComment-360193 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.