Im a new with PHP and i have this little problem. User asks from database granted access to site. Here is the script:
<?
function do_error($error) {
echo "<p><center>DO NOT, NOT TRY TO USE<br>";
echo "THIS SITE WITHOUT CORRECT USERNAME AND PASSWORD !!!<br>";
echo "REMEBER..... I TOLD YOU......";
die;
}
if (!$db = @mysql_connect("localhost","$loginname", "$pass")) {
$db_error = require("denied.php");
do_error($db_error);
}
if (!$ac = @mysql_select_db("myaccessdb")){
$db_error = require("denied.php");
do_error($db_error);
}
$sql = "SELECT *
FROM users
WHERE username='$PHP_AUTH_USER' and password='$PHP_AUTH_PW' and real_name='$real'";
//Execute the query and put results in $result
$result = mysql_query($sql);
// Get number of rows in $result. 0 if invalid, 1 if valid.
$num = mysql_numrows($result);
if ($num != "1") {
require("frameset.php");
}
?>
thats it.. on the frameset there is a page
that says: Access granted to and so on, script on this page is...
<?
$db = mysql_connect("localhost", "$loginname", "$pass");
mysql_select_db("myaccessdb",$db);
$result = mysql_query("SELECT * FROM users where username='$loginname' and password='$pass'",$db);
//echo " ACCESS GRANTED TO";
printf("%s<br>\n", mysql_result($result,0,"real_name"));
?>
this script works fine if it's on it's own page. Says nicly ACCESS GRANTED TO "REAL_NAME"..
it won't work if it is included somewhere else... IDEA of this is that after successful login one page on the frameset says Logged in "real_name"...
Im sure it can be done much easier.. but..
Please gimme a hand here.. thanks...