7.1

Table Of Contents
<input type="submit" value="Login"/>
</div>
</form>
The process_login.php file retrieves the user name and password send by the login form (POST). The curl library, that comes
with PHP, is used to send the information to the external_person_access.php file. The return value is stored in a local variable
which is used by the index.php to show feedback to the user. In this case the index.php is shown no matter what the outcome
is of the authentication process. One could implement an option to show a different page when the authentication was suc-
cessful.
<!-- Process_login.php -->
<?
// The process_login.php file (the following process is an example and
// should be handled by your web site or portal)
$hCurl = curl_init(); //Initializes a new session and return a cURL handle
curl_setopt($hCurl, CURLOPT_URL, $_SERVER['HTTP_HOST']."/external_person_access.php");
curl_setopt($hCurl, CURLOPT_POST, 1);
curl_setopt($hCurl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($hCurl, CURLOPT_TIMEOUT, 10); // times out after 4s
curl_setopt($hCurl, CURLOPT_POSTFIELDS, "fcUserName=".$_REQUEST[fcUserName].
"&fcPassword=".$_REQUEST[fcPassword]); // add POST fields
$cReturn = curl_exec ($hCurl);
curl_close ($hCurl);
if ($cReturn != "0") {
//Success
$cReturn = urlencode($cReturn);
$fcUserName = $_REQUEST[fcUserName];
} else {
//Failed
$fcUserName = $_REQUEST[fcUserName];
$cReturn = false;
}
include_once("index.php");
?>
Important: The PHP urlencode() function is applied to the encrypted password to make sure that it is properly encoded
when using it in a URL (f.e. Href).
In our example a few simple statements are used to show the return value of the authentication process.
<!-- Index.php -->
<!-- Statements to show the return value -->
<?
// Following variables are generated by process_login.php and
// used to show the repsonse of PSW.
if(isset($cReturn)){
if($cReturn == false){
echo "<div class=\"status error\">Invallid user name or password!</div>";
} else {
echo "<div class=\"status success\">Authentication successful,
©2010 Objectif Lune Inc - 202 -