PHP Classes

File: examples/extended-example.php

Recommend this page to a friend!
  Classes of Tony   twzAuth   examples/extended-example.php   Download  
File: examples/extended-example.php
Role: Example script
Content type: text/plain
Description: example script
Class: twzAuth
Authenticate users using HTTP Basic authentication
Author: By
Last change:
Date: 9 years ago
Size: 1,273 bytes
 

Contents

Class file image Download
<?php
/*
    Example - basic entry page for twzAuth (extended mode)
    ------------------------------------------------------
   
    Only valid, authenticated users can view this page.
    Admin users will get a link to admin.php
   
*/


// clumsy "logout" (for testing only)..
if(isset($_POST['logout']))
    { unset(
$_SERVER['PHP_AUTH_USER']); }


require
'extended-include.php';


?><!DOCTYPE HTML>
<html lang="en">
<head>
    <title>twzAuth (extended mode)</title>
    <meta http-equiv="content-type" content="text/html;charset=utf-8" />
    <style> form { display:inline; } </style>
</head>
<body>

<h2>Welcome <?php echo $Username; ?></h2>
<p>If you can see this page, you have authenticated successfully in <b>extended mode</b>.</p>

<?php
if($auth->isAdmin())
    { echo
'<p><a href="extended-admin.php">User admin</a></p>'; }
?>

<p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p>

<div>There is no "logout" facility with HTTP authentication (except <br />
    by restarting the browser). For testing purposes you can <br />
    click <form method="post"><input type="submit" name="logout" value="&quot;logout&quot;" /></form>,
    and then cancel the subsequent dialog.</div>

<p><a href="./">home</a></p>

</body>
</html>