2.1

PrintShop Web Web Integration Guide | 9
<!-- 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,
your todays secret password is: ".$cReturn."</div>";
}
}
?>