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

<?php
if(isset($_POST['send']))
{	
	$sql_update = "UPDATE `pd_brokers` SET `password` = '".md5($_POST['password'])."',`original_password` = '".$_POST['password']."' WHERE md5(user_id) = '".$_POST['hid_uid']."'";
	$exe_update = mysqli_query($connection,$sql_update);

    $_SESSION['sec_msg'] = 'Password reset successfully.';
	header("location: reset-password.php?uid=".$_POST['hid_uid']);
    exit;
}
?>

			<script language="javascript" type="text/javascript">
			function form_validation()
			{
				if(document.getElementById('password').value == "")
    			{
    				alert("Please enter password");
    				document.getElementById('password').focus();
    				return false;
    			}
    		   
    			if(document.getElementById('cpassword').value == "")
    			{
    				alert("Please enter confirm password");
    				document.getElementById('cpassword').focus();
    				return false;
    			}
    			
    			if(document.getElementById('cpassword').value != document.getElementById('password').value)
    			{
    				alert("Password and confirm password should be same");
    				document.getElementById('cpassword').focus();
    				return false;
    			}
			}
			</script>

			<!-- page template area start -->
    			<section id="about">
    				<div class="container mt-10 pb-10 pt-0">
    					<div class="row">
    					    <div class="col-md-5">
							    <?php require_once("left_panel.php");?>
						    </div>
    						<div class="col-md-7">
    							<h1 class="title mt-0 mb-10">Reset Password</h1>
								<?php if(isset($_SESSION['sec_msg'])) { ?>
        						<p><img src="images/tick.png" alt="" /> <?php echo $_SESSION['sec_msg'];?></p>
        						<?php 
        						unset($_SESSION['sec_msg']);
        						} 
        						?>	
    							<form id="" action="" method="post" enctype="multipart/form-data" class="contact-form" onsubmit="return form_validation();">
        						<div class="row">
        							<div class="col-lg-12 form-group">
        								<input name="password" id="password" placeholder="Enter Password *" class="common-input form-control" type="password">
        							</div>
        							<div class="col-lg-12 form-group">
        								<input name="cpassword" id="cpassword" placeholder="Enter Confirm Password *" class="common-input form-control" type="password">
        							</div>
        							<div class="col-lg-12 form-group">
    								    <button class="btn btn-flat btn-theme-colored border-left-theme-color-2-4px" type="submit" style="float: left;">Reset</button><input type="hidden" name="send" id="send" value="1" /><input type="hidden" name="hid_uid" id="hid_uid" value="<?php echo $_GET['uid'];?>" />
    							    </div>
    							</div>
    							</form>
    						</div>
    					</div>
    				</div>
    			</section>
    		</div>
			<!-- page template area end -->

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