Salve a tutti, sto cercando di catturare alcuni dati da pagine che possono essere accedute dopo la compilazione di un form. Sto imparando ad utilizzare CURL per fare ciò. In particolare utilizzo il seguente codice:
Codice PHP:
<?php
// Set the URL that will handle the POST variables
$url = 'http://www.site.com';
// Set username and password values below...
$username = 'username';
$password = 'password';
// Initialize cURL
$ch = curl_init();
// Set the URL
curl_setopt($ch, CURLOPT_URL, $url);
// Accept cookies
curl_setopt($ch,CURLOPT_COOKIEFILE,1);
// Submit our POST values (EG: username and password)
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "username=$username&password=$password");
// Execute...
$output = curl_exec($ch);
// Display the result
echo $output;
?>
Mi è, però, sorto un dubbio. Se nella pagina in questione avessi 2 o più form come posso specificare nel codice a quale di essi deve essere inoltrata la richiesta?