ok this is how you do it!
you have a file called
accesscontrol.php
in it you have main things like
1) start sessions
2) check for username and password in SESSION variables and POST variables (post to see if just logged in) then put ether one in $username and $password
3) SELECT username, password WHERE username = '$username' in the
database
dont do anything if it matchs just make if statments to detect no comparisons. do a if for username and password
if($username !=$db_username)
{
login("Username is invalid");
}
5) login function basically the same as the one you have right there! except to do this login("Username is invalid"); you have to make the function like this
function login($message)
{
code here
echo message somewhere
}
so basically
it starts a session or uses existing one then checks for variables username and password from $SESSION and $POST. sets them into variables $username and $password. then it checks them with ones in the database for a matching row WHERE username = '$username'. then you check the username and password in if statements!
thats the main jist of it! hope that helps basically wut u do then is lets say you have members.php and u want to make that a login restricted page! then u just include 'accescontrol.php'!
works great 🙂
good luck give me a shout on my email or pm me theres a good tutorial for it
hope that helps you 🙂