Jump to content

Posting and more


thiggins09

Recommended Posts

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

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.