You just write small logic in one page called login_check.php...
and you must include that file in every page where ever you want security to your page:
like:
<? include("login_check.php"); ?>
In login_check.php:
<?
session_start();
if(empty($_SESSION['user_name']))
{
header('location:index.php');
}
?>
Shanti C
Posting Virtuoso
1,642 posts since Jul 2008
Reputation Points: 137
Solved Threads: 162
And tel me where you are going to compare your username and password...
I think that is from database...
tel me...
Shanti C
Posting Virtuoso
1,642 posts since Jul 2008
Reputation Points: 137
Solved Threads: 162
My reply will be the solution for your line...
what if somebody, instead of going thru the normal procedure (from a.php to b.php after verification), directly types in the url for b.php into the address bar???
Shanti C
Posting Virtuoso
1,642 posts since Jul 2008
Reputation Points: 137
Solved Threads: 162
And tel me where you are going to compare your username and password...
I think that is from database...
tel me...
here is the code for redirecting if username and password are correct...
<?
session_start();
include('functions.php');
if($_SERVER['REQUEST_METHOD']=="POST"){
$qer="select * from table where username='".$_POST['username']."' and password='".$_POST['password']."'";
$res=mysql_query($qer);
$num=mysql_num_rows($res);
if($num==0)
{
echo'<script language="javascript">window.location.href="anotherpage.php";</script>';
}
else if($num==1)
{
session_unregister("user_name");
session_register("user_name");
$_SESSION['user_name']=$_POST['username'];
echo'<script language="javascript">window.location.href="welcome.php";</script>';
}
}
?>
Shanti C
Posting Virtuoso
1,642 posts since Jul 2008
Reputation Points: 137
Solved Threads: 162
see above answer which i have posted...
Shanti C
Posting Virtuoso
1,642 posts since Jul 2008
Reputation Points: 137
Solved Threads: 162