Als erstes brauchen wir den Inhalt der Website. Den kriegen wir entweder durch fsockopen, aber wir sind cool und benutzen cURL:

$postfields = 'formid=login&username=benutzername&';
$postfields .= 'password=passwort&submit=%C2%BB+Login';
 
$cp = curl_init('https://www.example.com');
curl_setopt($cp, CURLOPT_POST, true);
curl_setopt($cp, CURLOPT_POSTFIELDS, $postfields);
curl_setopt($cp, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($cp, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($cp, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($cp, CURLOPT_RETURNTRANSFER, true);
 
$output = curl_exec($cp);
curl_close($cp);

Erfahre hier, wie man die Website mit XPath ausliest.