Hey guys heres the problem I am encountering, I want to validate someones login by comparing it against their webmail account at school. To do this I would be using php to post a form via CURL with their username and password and searching the returned result for whether the person was able to login or not.
I have setup a dummy form like the one below which allows me to login when I input my correct information.
<form action="https://webmail.drexel.edu/login.msc" method="post" name="loginform">
<input type="text" name="user">
<input type="password" name="password">
<input type="submit" value="send">
</form>
To make PHP submit a form similar to this via CURL heer is the code im using:
<?php
$request = ""; //initialise the request variable
$param["user"] = ""; //this is the username
$param["password"] = ""; //this is the password
foreach($param as $key=>$val) //traverse through each member of the param array
{
$request.= $key."=".urlencode($val); //we have to urlencode the values
$request.= "&"; //append the ampersand (&) sign after each paramter/value pair
}
$request = substr($request, 0, strlen($request)-1); //remove the final ampersand (&) sign from the request
$url = "https://webmail.drexel.edu/login.msc"; //although we have used https, you can also use http
$ch = curl_init(); //initialize curl handle
curl_setopt($ch, CURLOPT_URL, $url); //set the url
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); //return as a variable
curl_setopt($ch, CURLOPT_POST, 1); //set POST method
curl_setopt($ch, CURLOPT_POSTFIELDS, $request); //set the POST variables
$response = curl_exec($ch); //run the whole process and return the response
curl_close($ch); //close the curl handle
echo $response;
?>
When I fill in the param user and password with my correct information the response written to the screen is simply the number "1". Anyone have any ideas why this isnt working? I used this code to make a form post to another site fine in the past.