thiggins09 Posted December 31, 2007 Share Posted December 31, 2007 Hi I have been researching this for a while but can’t seem to figure out a solution. There’s a page, that cannot be changed, that takes variables passed through the POST command which determine and display a certain notice. Is there some (magical) way to simulate a POST command server side, and then do a file_get_contents() to store what the page writes? I know you can use cUrl to simulate POSTs but how can you "download" the page after? Any help would be greatly appreciated. Link to comment https://forums.phpfreaks.com/topic/83822-posting-and-more/ Share on other sites More sharing options...
Northern Flame Posted December 31, 2007 Share Posted December 31, 2007 hmm... try using cURL() like you mentioned above, and then try telling the script to download the page you are on after you run cURL(), something like this: <?php function Post($vars,$url){ $ch = curl_init(); curl_setopt($ch,CURLOPT_URL,$url); curl_setopt($ch,CURLOPT_POST,1); #curl_setopt($ch,CURLOPT_UPLOAD,1); curl_setopt($ch,CURLOPT_POSTFIELDS,$vars); curl_exec($ch); curl_close($ch); } $url = "http://www.your-website.com/script.php"; $vars = "name=john&sex=male&weight=160"; // Desired Post Data Post($vars,$url); file_get_contents($url); ?> Link to comment https://forums.phpfreaks.com/topic/83822-posting-and-more/#findComment-426560 Share on other sites More sharing options...
thiggins09 Posted December 31, 2007 Author Share Posted December 31, 2007 Hi Thank you for replying. I applied this and the Post function seems to output the code to the page? Link to comment https://forums.phpfreaks.com/topic/83822-posting-and-more/#findComment-426808 Share on other sites More sharing options...
Northern Flame Posted December 31, 2007 Share Posted December 31, 2007 oops, i forgot something, try this: <?php function Post($vars,$url){ $ch = curl_init(); curl_setopt($ch,CURLOPT_URL,$url); curl_setopt($ch,CURLOPT_POST,1); #curl_setopt($ch,CURLOPT_UPLOAD,1); curl_setopt($ch,CURLOPT_POSTFIELDS,$vars); curl_exec($ch); curl_close($ch); } $url = "http://www.website.com/post.php"; // URL Where You Want The Post Data To Go To $vars = "name=john&sex=male&weight=160"; // Desired Post Data $my_url = $_SERVER['REQUEST_URI']; // Your URL Post($vars,$url); file_get_contents($my_url); ?> Link to comment https://forums.phpfreaks.com/topic/83822-posting-and-more/#findComment-426902 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.