<?php
date_default_timezone_set("Asia/Jakarta");
include 'config.php';
session_start();
$error = '';
if (isset($_POST['submit'])) {
if (empty($_POST['username']) || empty($_POST['password'])) {
$error = "Username or Password is invalid";
}
else{
    $username = $_POST['username'];
    $password = $_POST['password'];
    $query = "SELECT username, password from novia_abc_users where username=? AND password=? LIMIT 1";
    // To protect MySQL injection for Security purpose
    $stmt = $conn->prepare($query);
    $stmt->bind_param("ss", $username, $password);
    $stmt->execute();
    $stmt->bind_result($username, $password);
    $stmt->store_result();
    if($stmt->fetch()){
		$_SESSION['login_user'] = $username; // Initializing Session
		setcookie("login_user", $username, time() + (86400 * 1), "/");
	}
    header("location: index.php");
}
mysqli_close($conn);
}