Hocu da napravim neki login za administraciju vijesti.
I u index.php stranicu ubaceno je:
<? require("auth.php"); ?>
auth.php se sastoji iz sledeceg:
----------------------------------------------------------------------
----------------------------------------------------------------------
<?php
function access_denied() {
echo "401 Unauthorized: The username / password combination you entered was $PHP_AUTH_USER invalid.\n";
}
function auth_headers($title) {
Header("WWW-Authenticate: Basic realm=\"$title\"");
Header("Status: 401 Unauthorized");
# Header("HTTP/1.0 401 Unauthorized");
}
else {
include ("mojabaza.php");
$database = "imebaze";
$username = "$PHP_AUTH_USER";
$query = "select username,password from login where username='$PHP_AUTH_USER' and password=password('$PHP_AUTH_PW');";
if (mysql_num_rows(mysql_db_query($database, $query)) == 0) {
auth_headers("News Administration");
access_denied();
exit;
}
}
$usernamei = mysql_query("select * from login where username='$PHP_AUTH_USER'");
$cntrowun = mysql_fetch_array($usernamei);
$username = $cntrowun[username] ;
$userstatus = $cntrowun[status] ;
?>
----------------------------------------------------------------------
----------------------------------------------------------------------
mojabaza.php se sastoji iz sledeceg:
----------------------------------------------------------------------
----------------------------------------------------------------------
<?php
$dbcn = mysql_connect("localhost", "user", "pass");
#$dbcn = mysql_connect("localhost", "root", "hopkins12");
mysql_select_db("imebaze", $dbcn);
?>
----------------------------------------------------------------------
----------------------------------------------------------------------
Napravljena je i baza imebaze koja sadrzi sva potrebna polja.
Kada idem na index.php pojavi se popup i trazi username i password:
Ja ukucam neki koji sam unio u bazu on nece da ga prihvati i naravno,
tada ispisuje poruku:
The username / password combination you entered was invalid.
Napominjem da i svaki user ima i svoj status i kada se uloguje zna se
sta mu je dozvoljeno.
Ajde pomozite sto prije...