I've created user registration and login system...below I have the code for logging the user in:
<?php
$user=$_REQUEST['username'];
$pass=$_REQUEST['password'];
$user=strip_tags($user);
$pass=strip_tags($pass);
$user=str_replace(" ", "",$user);
$pass=str_replace(" ","",$pass);
$user=str_replace("%20", "",$user);
$pass=str_replace("%20", "",$pass);
$user=addslashes($user);
$pass=addslashes($pass);
$connection=mysql_connect("localhost", "db_username", "$db_password");
$mysql_select_db("databasename")
$pass=md5($pass);
$request="SELECT * FROM users WHERE password='".$pass."' AND username='".$user."'";
$results=mysql_query($request, $conn);
if(mysql_num_rows($results)}
{
echo"User logged in"
$_SESSION['user']=$user;
$_SESSION['auth']=true;
}
else
{
echo"The Username or Password you have entered is invalid. Please go back and try again or procede to our <a href="signup.php">registration</a> page.";
$_SESSION['auth']=false;
}
?>
I've been reading up on sessions now for quite a time and I'm having trouble understanding how to use sessions in terms of navigating around the website once the user is logged in. For example, once the user is logged in, I want the user to be able to customize options and such. Also, to restrict certain pages of my website if the user is not logged in.