Hi psn
There are many ways to do your job done for you.
One way of doing things HTTp authentication stuff let me show u that. It is purely php stuffs. If this code doesn't surve you tell me let me help u with something else ok
Code:
<?php
header ("Cache-Control: no-cache, must-revalidate");
header ("Pragma: no-cache");
if ((!isset( $PHPAUTHUSER )) || (!isset($PHPAUTHPW)))
{
header( 'WWW-Authenticate: Basic realm="Please Login"' );
header( 'HTTP/1.0 401 Unauthorized' );
//if the user press cancel the redirect to some page
print '<meta http-equiv="refresh" content="0;URL=login.php">';
exit;
}
else
{
//if the user give the name and password then do your stuffs
// these are some server side includes for my sql stuffs
include "../include/database.php";
include "../include/mdbc.inc.php";
//connect the database
$sql = new db($siteusername, $sitepassword);
//select the database
$sql->setdb($sitedatabase);
$querycommand = "select useruserid,userpassword from userdetails where userloginname ='$PHPAUTHUSER'";
$query2 = new query($sql, $querycommand);
if($query2->numrows==0)
{
//when no user is present with that name
unset ($PHPAUTHUSER,$PHPAUTHPW);
print '<meta http-equiv="refresh" content="0;URL=login.php?ans=1">';
die('-');
}
else
{
//now check for usernama and password
$query2->fetchrow();
$userid = $query2->rowdata[0];
$userpass = $query2->rowdata[1];
if ($userpass==$PHPAUTHPW)
{
//verification over
}
else
{
//password wrong redirect to some page
unset ($PHPAUTHUSER,$PHPAUTHPW);
print '<meta http-equiv="refresh" content="0;URL=login.php?ans=2">';
die('-');
}
}
}
?>
Enter your message below
Sign in or Join us (it's free).