PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I need to use a PHP script to load a website with some POST-passed variables. If it were a human doing it, he'd just enter the values into the textboxes..can a script do it? Is it sent in the headers? Thanks!
EDIT, okay the above answered that...now what if i want to save the HTML of the page that results? In the ablove example, would $content hold what I need?
$ch = curl_init(); //initialize handle
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //return data from cURL execution rather than outputting to browser
curl_setopt($ch, CURLOPT_POST, 1); //enable POST
curl_setopt($ch, CURLOPT_POSTFIELDS, $postData); //where $postData = "value1=whatever&value2=whatever"
curl_setopt($ch, CURLOPT_URL, $yourURL); //set the page you want to access
$pageData = curl_exec($ch); //and you're on your way
See? Not so bad.
[EDIT] Looks like I'm slow... [/EDIT]
Last edited by RobertPaul on Wed Dec 07, 2005 9:14 pm, edited 1 time in total.
Your post values, look at the above snipplet I just posted. Also are you wanting to grab the results of the page? For instance, is your page returning a specific value your supposed to grab to determine the output?
For example, on several credit card gateways our API tells the user what values are expected back, upon a transaction.. usually in the form of
This is still a concept to me, I don't have any proctical uses for it (yet), I just want to see if I can use a POST and grab the HTML of the resulting page. I might then look for certain strings or whatever I choose to use it for.