tomjones Posted July 24, 2006 Share Posted July 24, 2006 Hi.If for example I have a variable, foo, which creates a random number,how can I pass this variable to an html page and append it to a url.An example of what I would like to achieve is:www.domain.com/file.html&foo=145365432where the user would see file.html and file.html would receive foo=145365432I had a similar request not long ago but was unable to extrapolate from it. Thank you very much for your attention. Link to comment https://forums.phpfreaks.com/topic/15528-passappend-variable-to-url/ Share on other sites More sharing options...
GingerRobot Posted July 24, 2006 Share Posted July 24, 2006 Well you add the variable to the user either by having a form with the action of get, or simply redirectiong the user to the page with the variable in the url, e.g.header("location:page.php?var=12414");However, unless your server is set up to pass html files like php, i dont think you are going to be able to retrieve the variable and its contents in your html page.However, you do it like this:$var = $_GET['var']; Link to comment https://forums.phpfreaks.com/topic/15528-passappend-variable-to-url/#findComment-63074 Share on other sites More sharing options...
ChaosXero Posted July 24, 2006 Share Posted July 24, 2006 You would need to pass the number as a post variable from a form. For example:User posts form with number to get_form.php.get_form looks for $_POST['rand'].user just sees get_form.php. If you dont mind the number showing in the url, just have it $_GET instead of post and you wont need to post from a form, but rather file.php?foo=number Link to comment https://forums.phpfreaks.com/topic/15528-passappend-variable-to-url/#findComment-63077 Share on other sites More sharing options...
tomjones Posted July 24, 2006 Author Share Posted July 24, 2006 Thanks for your help guys, that works perfectly. Link to comment https://forums.phpfreaks.com/topic/15528-passappend-variable-to-url/#findComment-63106 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.