http://www.electrictoolbox.com/php-curl-sending-username-password/ has a good article on how to do this.
Use the code they suggested:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
$output = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);
and if you know some telling bit of source code in the page after the password was sent that differentiates a failed attempt from a successful one (for example if the login worked it may say "login successful"), and test the returned code.