Skip to content
Permalink
1fc184b196
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
52 lines (46 sloc) 1.58 KB
<?php
session_start();
include 'db_conn.php';
if (isset($_POST['email']) && isset($_POST['password']))
{
$email = $_POST['email'];
$password = $_POST['password'];
if(empty($email))
{
header("Location: login.php?error=Email is required&email=$email");
}else if(empty($password))
{
header("Location: login.php?error=Password is required!");
}else
{
$stmt = $conn->prepare("select * from users where email=?");
$stmt->execute([$email]);
if ($stmt->rowCount() === 1)
{
$user = $stmt->fetch();
$user_id = $user['id'];
$user_full_name = $user['full_name'];
$user_email = $user['email'];
$user_password = $user['password'];
if ($email === $user_email)
{
if (password_verify($password, $user_password))
{
$_SESSION['user_id'] = $user_id;
$_SESSION['user_email'] = $user_email;
$_SESSION['user_full_name'] = $user_full_name;
header("Location: index.php");
}else
{
header("Location: login.php?error=Incorrect Username or Password&email=$email");
}
}else
{
header("Location: login.php?error=Incorrect Username or Password&email=$email");
}
}else
{
header("Location: login.php?error=Incorrect Username or Password&email=$email");
}
}
}