ohctech_p8/includes/auth/auth.php

33 lines
737 B
PHP
Raw Normal View History

2024-11-02 11:02:15 +05:30
<?php
$host_name="localhost";
$database_name="volvo";
$database_user="root";
$database_password="";
2024-10-16 19:18:52 +05:30
2024-11-02 11:02:15 +05:30
$conn = mysqli_connect($host_name,$database_user,$database_password,$database_name,3306);
2024-10-16 19:18:52 +05:30
2024-11-02 11:02:15 +05:30
$username=$_SESSION['username'];
$password=$_SESSION['userpassword'];
2024-10-16 19:18:52 +05:30
//session_cache_expire(60);
2024-11-02 11:02:15 +05:30
if(!validate($username, $password,$conn)){
2024-10-16 19:18:52 +05:30
@header("Location: index.php?msg=Session Expired Please Login Again");
}
2024-11-02 11:02:15 +05:30
function validate($username, $password,$conn)
2024-10-16 19:18:52 +05:30
{
2024-11-02 11:02:15 +05:30
if($username=="" || $password=="" )
{
2024-10-16 19:18:52 +05:30
return false;
}
2024-11-02 11:02:15 +05:30
$sql="select * from tbl_users where user_name='".$username."' AND user_password='".$password."'";
$result=mysqli_query($conn, $sql);
if(mysqli_num_rows($result) > 0)
{
2024-10-16 19:18:52 +05:30
return true;
2024-11-02 11:02:15 +05:30
}
else
{
2024-10-16 19:18:52 +05:30
return false;
}
}