<?php
session_start();
if (!$_SESSION["loggedin"]) {
session_destroy();
header("Location: http://www.yourdomain.com/imspClient/login.html");
}
require("cIMSPABook.php");
//remember, for our example the addressbook name is the same as the username
$abookname = $_SESSION["username"];
?>
<html>
<head>
<title>Untitled</title>
</head>
<body>
<TABLE Border=1>
<?php
//Recreate a new IMSPAddressBook object
$imsp = new IMSPAddressBook();
//Login again with the user/pass stored in the session variables
//Note: This is a simple example and contains no error handling for failure.
$imsp->login($_SESSION["username"],$_SESSION["pass"]);
/* Recieve an associative array of the requested entry.
* Note that the name of the entry is passes in the query string so we get to it
* with $_REQUEST["entry"] since it is recommended to keep register_globals = Off
*/
$name = $imsp->getAddressBookEntry($abookname,$_REQUEST["entry"]);
//Logout of the IMSP server...NOT the PHP session.
$imsp->logout();
//Build the table.
while(list($key,$value) = each($name)) {
echo("<TR><TD>$key</TD><TD>$value</TD></TR>\n");
}
//Kill the PHP session since we are done. Note that this would normally be provided as a "logout" button
//in out final application.
session_destroy();
?>
</TABLE>
</body>
</html>
|