I have defined my session in my login page. Once user and password is entered it lands to predefine url page. Problem that I can access my other pages with url I want to protect pages with login session.
<?php
session_start();
if(isset($_POST['submit'])){
$user=$_POST['user'];
$password=$_POST['password'];
$query="SELECT * FROM login WHERE user='$user' && password='$password'";
$data=mysqli_query($db_conn,$query);
$total=mysqli_num_rows($data);
if($total==1) {
echo("Login Sucessfull");
$_SESSION['log']=1;
header("refresh:2;url=customer_data_ie.php");
}
elseif($total==is_null()){
echo("Invalid User");
header("refresh:2;url=login_page_crm.php");
}
else{
echo "Invalid User";
}
}
?>
<?php
session_start();
session_destroyed();
?>
For this You have to follow below steps :
This is reduce code duplication
and you will easily manage your web apps.
Let me give you an example of dir stucture
/inc/header.php, footer.php
/system/config.php
include header.php inside this config.php and include config.php in all the pages so this will include your configuration and header / footer as well.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.