<?php 

ob_start();

session_start();

include_once("../functions.php");

$conn = dbconnect();

if($_SESSION['isadmin'])
header("Location: index.php");

include "headers/headerlogin.php";



if($_POST['login'])

{

$username = mysqli_real_escape_string($conn,$_POST['username']);

$password = md5($_POST['password']);



$login_query = "SELECT * FROM adminusers WHERE uname='".$username."' AND upasswd='".$password."' AND ustatus=1";



$validate = mysqli_query($conn,$login_query);



$valid = mysqli_num_rows($validate);



if($valid==1)

{

	$admin_info = mysqli_fetch_array($validate);

	$_SESSION['userid'] = $admin_info['id'];	

	$_SESSION['loginname'] = $admin_info['uname'];

	$_SESSION['isadmin'] = 1;
	
	if($admin_info['country_login']==1) {
	$_SESSION['country_login'] = 1;
	$_SESSION['country_access'] = explode(",",$admin_info['countries']);
    $_SESSION['country_access_array']	=  "'".implode("','", $_SESSION['country_access'])."'";
	}
	else if($admin_info['country_login']==2) {
	$_SESSION['country_login'] = 2;
	$_SESSION['country_access'] = explode(",",$admin_info['countries']);
    $_SESSION['country_access_array']	=  "'".implode("','", $_SESSION['country_access'])."'";
	}
	else {
	$_SESSION['country_login'] = 0;
	}

	

	/*if($_POST['ref'])

	header("Location: ".$_POST['ref']);

	else*/

	header("Location: clubs.php?page=1");

}





}

?>

<div class="page-form">

    <form action="login.php" class="form" method="POST">

        <div class="header-content"><h1>Administration Log In</h1></div>

        <div class="body-content"><p>Log as admin here:</p>



            <div class="row mbm text-center">

            

            </div>

            <div class="form-group">

                <div class="input-icon right"><i class="fa fa-user"></i><input type="text" placeholder="Username" name="username" class="form-control"></div>

            </div>

            <div class="form-group">

                <div class="input-icon right"><i class="fa fa-key"></i><input type="password" placeholder="Password" name="password" class="form-control"></div>

            </div>

            <!-- div class="form-group pull-left">

                <div class="checkbox-list"><label><input type="checkbox">&nbsp;

                    Keep me signed in</label></div>

            </div -->

            <div class="form-group pull-right">

                <button type="submit" class="btn btn-success" value="Log In" name="login">Log In

				

                    &nbsp;<i class="fa fa-chevron-circle-right"></i></button>

            </div>

            <div class="clearfix"></div>

            <div class="forget-password"><h4>Forgotten your Password?</h4>



                <p>no worries, click <a href='#' class='btn-forgot-pwd'>here</a> to reset your password.</p></div>

            <hr>

			<p><b>By any chance if you are not ADMINISTRATOR you can go back from <a id="btn-register" href="https://www.golfsurprize.com">HERE</a></b></p></div>

            </div>

			<?php if($_GET['ref']) {?>

					<input type="hidden" name="ref" value="<?php echo $_GET['ref'];?>">

					<?php }?>

    </form>

</div>

<script src="js/jquery-1.10.2.min.js"></script>

<script src="js/jquery-migrate-1.2.1.min.js"></script>

<script src="js/jquery-ui.js"></script>

<!--loading bootstrap js-->

<script src="vendors/bootstrap/js/bootstrap.min.js"></script>

<script src="vendors/bootstrap-hover-dropdown/bootstrap-hover-dropdown.js"></script>

<script src="js/html5shiv.js"></script>

<script src="js/respond.min.js"></script>

<script src="vendors/iCheck/icheck.min.js"></script>

<script src="vendors/iCheck/custom.min.js"></script>

<script>//BEGIN CHECKBOX & RADIO

$('input[type="checkbox"]').iCheck({

    checkboxClass: 'icheckbox_minimal-grey',

    increaseArea: '20%' // optional

});

$('input[type="radio"]').iCheck({

    radioClass: 'iradio_minimal-grey',

    increaseArea: '20%' // optional

});

//END CHECKBOX & RADIO</script>

<?php include "footer.php";?>