mlindal Posted September 8, 2005 Posted September 8, 2005 How do I capture the current query that got me to a particular php page? ie. if the url in the header is: http://domain.com/publist.php?name=tree&year=2005 And I want to capture the part of the url past the '?' something like this: $query = parse_url(['query']); in old cdml it was using the FMP-Link command and in perl it is $ENV{'QUERY_STRING'} So what small part am I missing? Thanks
mlindal Posted September 8, 2005 Author Posted September 8, 2005 further to this, I am trying to get the query from a 'POST' form rather than a 'GET' so all variables are hidden. I think there must be something I can do with $_REQUEST The goal is to take the variables from one page and send the variables (query) to another PHP page.
Garry Claridge Posted September 9, 2005 Posted September 9, 2005 Try this: $_SERVER["QUERY_STRING"] Garry
mlindal Posted September 12, 2005 Author Posted September 12, 2005 Thanks Gary, $_SERVER["QUERY_STRING"] works excellent for 'GET' but if for security I want to use 'POST' on the form and keep all fields hidden, that won't work. So then I am left with having the $_REQUEST capturing all the fields (GET, POST, COOKIE) and wanting to send those fields to a new PHP page. Page1.php takes all the data from a form via POST. All the fields are hidden, so the only way I see is to use $_REQUEST or $_POST. I then want take those fields and keep them hidden and send them to a second page (Page2.php). So... please help with the following and feel free to make corrections. I might try to take the array $_POST and save it to a new array. $variables = $_POST; I then might try the following to pass it to the new page.
Garry Claridge Posted September 13, 2005 Posted September 13, 2005 For a POST I've used this before: $args = ""; while ($fm_params = Current($_REQUEST)) { $args .= urlencode(key($_REQUEST)) . "=" . urlencode($fm_params) . "&"; next($_REQUEST); }; //echo $args; $content = @file_get_contents("http://localhost:591/FMPro?" . $args); Good Luck. Garry
mlindal Posted September 13, 2005 Author Posted September 13, 2005 Thanks Gary, good idea. What I did do that seems to work is take all the items from the POST and put them into a form so that this form can then be posted to a new page (similar trick to the next and Prev in a long list of items) Francais The javascript eliminates the huge submit button.
Garry Claridge Posted September 13, 2005 Posted September 13, 2005 I've just remembered about this one. I used CURL to create a POST from a query string. However, you woud be able to use the "while ($fm_params = Current($_REQUEST))" loop to construct the CURLOPT_POSTFIELDS list, then use this to send it: <?php $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "http://localhost:591/FMPro"); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, "-db=combotest.fp5&-format=-fmp_xml&-findall"); curl_exec($ch); curl_close($ch); ?> All the best. Garry
Recommended Posts
This topic is 7080 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now