<?php
session_start();
include_once("../include/dbconnect.php");
if(isset($_POST['login_btn']))
{
$email = mysqli_real_escape_string($conn, $_POST['email']);
$password = mysqli_real_escape_string($conn, $_POST['password']);

$login_query = "SELECT * FROM users WHERE email='$email' AND password='$password'";
$login_query_run = mysqli_query($conn, $login_query);

if(mysqli_num_rows($login_query_run) > 0)
{


$userdata = mysqli_fetch_array($login_query_run);

 $username = $userdata['name'];
 $useremail = $userdata['email'];
 $_SESSION['auth'] =  $userdata['id'];

$_SESSION['auth_name']= $username;
$_SESSION['auth_email']= $useremail; 

$_SESSION['message'] = "Logged In Successfully";
 header('Location: ../gallery.php?mec_g_id=2&Content%20Editor');
//echo $_SESSION['message'];
}
else
{
    $_SESSION['message'] = "Invalid Credentials";
  header('Location: ../login.php');
 //  echo $_SESSION['message'];
}

}
?>