Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- error_reporting(0);
- require_once("includes/config.php");
- if (isset($_SESSION['admin']['id'])){
- header("location: dashboard.php");
- exit();
- }
- if(isset($_POST['login_btn'])){
- $error = array();
- $error = login();
- if(!count($error)){
- $check_user = "select * from `users` where email='".$_POST['username']."' and password='".$_post['password']."' ";
- $result_user = mysql_query($check_user);
- $result = mysql_fetch_assoc($result_user);
- if(isset($result['id'])){
- $_SESSION['admin'] = $result;
- unset($_SESSION['admin']['password']);
- header("location: dashboard.php");
- exit();
- }
- else{
- /*$msg_red = "Please Enter login details";*/
- header("location: dashboard.php");
- exit();
- }
- }
- }
- ?>
- <?php
- function login(){
- $error = array();
- if(empty($_POST['email'])){
- $error['email'] = "Please Enter Username";
- }
- else if(!filter_var($_POST['email'],FILTER_VALIDATE_EMAIL)){
- $error['email'] = "Please Provide Email";
- }
- else if(empty($_POST['password'])){
- $error['password'] = "Please Enter Password";
- }
- return $error;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement