dannybrazil Posted September 8, 2009 Share Posted September 8, 2009 Hello I wanted to know if its possible to do something like that : <a href="www.mysite.com?id=123&cat=456" method="post">click</a> and in the next page to capture the variables as POST? $id=$_post['id']; basically what i want is to pass the variables in the link BUT capture them as POST methos Danny Quote Link to comment https://forums.phpfreaks.com/topic/173557-passing-variables-in-a-link/ Share on other sites More sharing options...
pneudralics Posted September 8, 2009 Share Posted September 8, 2009 GET is for retrieving data and POST is for storing/updating data. So your link should look like this: <a href="www.mysite.com?id=123&cat=456">click</a> Once it goes to the page... you then use GET to get the variables from the url. Quote Link to comment https://forums.phpfreaks.com/topic/173557-passing-variables-in-a-link/#findComment-914849 Share on other sites More sharing options...
dannybrazil Posted September 8, 2009 Author Share Posted September 8, 2009 Hey This part of $_GET[''] i know.... the question was ...can i pass variables but not let them show in the URL (e.g POST like the form method) Quote Link to comment https://forums.phpfreaks.com/topic/173557-passing-variables-in-a-link/#findComment-914855 Share on other sites More sharing options...
cbolson Posted September 8, 2009 Share Posted September 8, 2009 Hi, If you really *have* to do this you could loop through all the $_GET values (ie the ones sent via the url) and add them the the $_POST array like this: foreach($_GET AS $key=>$val){ $_POST[$key]=$val; } Seems rather against the purpose of the $_POST variable though Chris Quote Link to comment https://forums.phpfreaks.com/topic/173557-passing-variables-in-a-link/#findComment-914864 Share on other sites More sharing options...
pneudralics Posted September 8, 2009 Share Posted September 8, 2009 Hey This part of $_GET[''] i know.... the question was ...can i pass variables but not let them show in the URL (e.g POST like the form method) You can use sessions or cookies. Quote Link to comment https://forums.phpfreaks.com/topic/173557-passing-variables-in-a-link/#findComment-914865 Share on other sites More sharing options...
mikesta707 Posted September 8, 2009 Share Posted September 8, 2009 passing the values the way you are currently is passing them by get values. What you can do is create hidden forms, and have that link submit the form that those hidden fields are part of, but you can't hide the get variables from the URL unless you use Mod rewrite or something like that. Quote Link to comment https://forums.phpfreaks.com/topic/173557-passing-variables-in-a-link/#findComment-914948 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.