Auth and header("Location:...") issues
| From: | wade | Date: | Fri, 18 Jul 2003 06:15:50 +0000 |
| Subject: | Auth and header("Location:...") issues | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-6659@lists.php.net to get a copy of this message | ||
Hi All:
I'm trying to use the Auth package and have a few questions:
PHP version 4.3.1
Apache version 1.3.27
Auth version 1.2.0
1) I'm trying to use the example in the top of the Auth.php file and place the
creation of the Auth object and the $myauth->start() code in a file that gets
included in all the pages I want to secure. I have a little example script
here that just secures the phpinfo() function as follows: (more below)
>>> begin phpinfo_test.php:
<?
include "auth_test.php";
if ($myauth->getAuth()) {
phpinfo();
}
else {
header("Location: http://www.ohthepainwilliam.com");
}
?>
>>> end phpinfo_test.php:
>>> begin auth_test.php
<?
require_once("Auth/Auth.php");
function loginFunction()
{
/**
* Change the HTML output so that it fits to your
* application.
*/
echo "<form method=\"post\" action=\"" .
$_SERVER['PHP_SELF'] . "\">";
echo "<input type=\"text\" name=\"username\">";
echo "<input type=\"password\" name=\"password\">";
echo "<input type=\"submit\">";
echo "</form>";
}
// define dsn
$dsn = "mysql://root:@localhost/customer";
// set options
$options = array(
'table' => 'customers',
'usernamecol' => 'userlogin',
'passwordcol' => 'password',
'dsn' => $dsn
);
// create auth object
$myauth = new Auth('DB', $options,"loginFunction");
$myauth->start();
?>
How do I load a different page upon an authentication failure?
2) Is this the way this is intended to be used???
Thanks,
Wade.
__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com