<?php require_once("header.php");?>

<?php
if(isset($_POST['send']))
{	
	$sql_check = "SELECT * FROM `pd_brokers` WHERE `broker_code` = '".$_REQUEST['broker_code']."' AND `password` = '".md5($_REQUEST['password'])."'";
    $exe_check = mysqli_query($connection,$sql_check);
    $num_check = mysqli_num_rows($exe_check);
    if($num_check>0)
    {
    	$arr_check = mysqli_fetch_array($exe_check);
    	if($arr_check['is_active'] == 'Yes')
    	{
    		$_SESSION['USER_ID'] = $arr_check['user_id'];
    		
    		header("location: my-account.php");
    	}
    	else
    	{
    		$_SESSION['msg_fail1'] = 'Your account is blocked by administrator';
    		header("location: broker-login.php");
    		exit;
    	}
    }
    else
    {
        $_SESSION['msg_fail'] = 'Invalid login credentials. Please try again!';
    	header("location: broker-login.php");
    	exit;
    }
}
?>


			<!-- page template area start -->
			<section id="about">
				<div class="container mt-10 pb-10 pt-0">
					<div class="row">
						<div class="col-md-5">
							<div class="">
								<?php require_once("left_panel.php");?>
							</div>
						</div>
						<div class="col-md-7">
							<h1 class="title mt-5 mb-15" style="text-align:left;">Brokerdost <span style="color:#ff8e00;">Login</span></h1> 
							<?php if(isset($_SESSION['msg_fail'])) { ?>
							<p class="text-left"><img src="images/cross.png" alt="" /> <?php echo $_SESSION['msg_fail'];?></p>
							<?php 
							unset($_SESSION['msg_fail']);
							} 
							?>
							<?php if(isset($_SESSION['msg_fail1'])) { ?>
							<p class="text-left"><img src="images/cross.png" alt="" /> <?php echo $_SESSION['msg_fail1'];?></p>
							<?php 
							unset($_SESSION['msg_fail1']);
							} 
							?>
							<form id="contact_form" name="contact_form" class="" action="" method="post" onSubmit="return form_validation();">
							<div class="row">
								<div class="col-sm-12">
									<div class="form-group">
										<input name="broker_code" id="broker_code" class="form-control" type="text" placeholder="Enter Code *" value="">
									</div>
								</div>
								<div class="col-sm-12">
									<div class="form-group">
										<input name="password" id="password" class="form-control" type="password" placeholder="Enter Password *" value="">
									</div>
								</div>
							</div>
							<div class="form-group">
								<input type="hidden" name="send" id="send" value="1" />
								<button type="submit" class="btn btn-flat btn-theme-colored border-left-theme-color-2-4px">Login Now</button>
							</div>
							</form>
							<p><a href="forgot-code.php">Forgot Code</a></p>
							<p><a href="forgot-password.php">Forgot Password</a></p>
							<p class="text-left"><a href="broker-signup.php" style="color:#e53935">New to Properti Dost? Create New Brokerdost Porichoi</a></p>
						</div>
					</div>
				</div>
			</section>
			<!-- page template area end -->

<?php require_once("footer.php");?>