Skip to content

Instantly share code, notes, and snippets.

@oimtrust
Created October 16, 2017 06:41
Show Gist options
  • Save oimtrust/1224e1c2bba93bf09bb407846e20b825 to your computer and use it in GitHub Desktop.
Save oimtrust/1224e1c2bba93bf09bb407846e20b825 to your computer and use it in GitHub Desktop.
<?php
/**
* Created by PhpStorm.
* User: oimtrust
* Date: 08/09/17
* Time: 14:55
*/
if(defined('RESTRICTED')) {
} else {
exit('No direct script access allowed!');
}
session_start();
//if logged in
if (isset($_SESSION['username'])){
$connect->redirect($baseurl . "4dm1n.php");
exit;
}
if (isset($_POST['btn_login'])){
$username = strip_tags($_POST['username']);
$password = strip_tags(md5($_POST['password']));
if ($username == ''){
$error[] = "Username masih kosong!";
}
elseif ($password == ''){
$error[] = "Password masih kosong!";
}
else {
$check = $connect->execute("SELECT * FROM tbl_admin WHERE username = '{$username}'");
if ($check->num_rows == 0){
$error[] = "Username tidak ada!";
}
else {
//saving user session
$login = $check->fetch_object();
if ($password == $login->password){
$_SESSION['username'] = $login->username;
$connect->redirect($baseurl.'4dm1n.php');
exit();
}
else {
$error[] = "Password anda salah!";
}
}
}
}
include 'apps/views/layouts/header.view.php';
include 'apps/views/admin/auth/login.view.php';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment