Session With Login

<?php
require_once('db.php');
global $conn,$db;
// If form submitted, insert values into the database.
//1st step data get with method....
if (isset($_POST['login_submit'])){
$email = $_POST['email'];
$password = $_POST['password'];
//2nd step query insert and check the connection.....
$sql_query = "SELECT * FROM `register` WHERE email='$email'";
$query = mysqli_query($conn,$sql_query) or die('Please check mysqli:'.$sql_query);
//3step result check in num rows with condition....
$result = mysqli_num_rows($query);
if($result > 0){
$rows=mysqli_fetch_array($query);
$db_password=$rows['password'];
if(md5($password) == $db_password){
$_SESSION['login_name'] = $email;
header("Location: fetch_data.php");
}else{
$_SESSION['msg'] ='password not match.';
header("Location: login_form.php");
}
}else{
$_SESSION['msg'] ='User not exit.';
header("Location: login_form.php");
}
}else{
header("Location: login_form.php");
}
?>

Comments

Popular posts from this blog

condition in table data for html

my notepad code notes

React.js Notes