limitedreality Posted April 28, 2010 Share Posted April 28, 2010 I'd assume this is a common task, maybe I'm just not searching it correctly. I need to post variables to a form processing page and parse a value from the submitted results page. I'm using curl to submit the post values but I'm struggling to figure out how store the returned page content, parse it for a specific value and return that value. Background: I'm not exploiting anything online, at my job I'm dealing with a closed source application that's no longer supported by the developer. We host it in house so I have full access to the backend database but there's no easy way to track the value assigned directly in the database from that specific request because of the concurrent activity on the application. Here's the code I use to pass the post values to the page (with url and post values removed). <?php $ch = curl_init('http://www.example.com'); curl_setopt ($ch, CURLOPT_POST, 1); curl_setopt ($ch, CURLOPT_POSTFIELDS,"FIELDS REMOVED"); curl_exec ($ch); curl_close ($ch); ?> Can anyone point me in the right direction or link me to an example of how I'd update this to get the returned page content into a variable or array to search? Thanks. Link to comment https://forums.phpfreaks.com/topic/200082-curl-post-values-return-string/ Share on other sites More sharing options...
cags Posted April 28, 2010 Share Posted April 28, 2010 If you set CURLOPT_RETURNTRANSFER then curl_exec will return the content returned by the URL. <?php $ch = curl_init('http://www.example.com'); curl_setopt ($ch, CURLOPT_POST, 1); curl_setopt ($ch, CURLOPT_POSTFIELDS,"FIELDS REMOVED"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $output = curl_exec ($ch); curl_close ($ch); ?> Link to comment https://forums.phpfreaks.com/topic/200082-curl-post-values-return-string/#findComment-1050145 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.