<script>
if ( window.history.replaceState ) {
  window.history.replaceState( null, null, window.location.href );
}
</script>

<?php
	if(isset($_POST['email']))
	{
		$newPin = rand(1000, 9999);
		
		$alt_message = 'Old pin was reset. The new pin is: <b>' . $newPin . '</b>';
		$subject = 'Resetare pin';
		$sendName = $_POST['email'];
		$sendEmail = $_POST['email'];
		
		update_lost_pin($_POST['email'], $newPin);
		$html_mail = 'Old pin was reset. The new pin is: <b>' . $newPin . '</b>';
		include 'include/functions/sendEmail.php';
	}
?>

<div>
    <div class="">
        <div class="">
            <form role="form" method="post" action="">
				<div class="page-hd" style="background-image: url(<?php print $site_url; ?>images/user.png)">
					<div class="bd-c">
						<h2 class="pre-social">Reset pin</h2>
					</div>
				</div>
				<div class="content-body">
				<table class="table table-responsive-md ranking">
					<tbody>
						<tr>
							<td>Email:</td>
							<td><input class="form-control" name="email" maxlength="64" placeholder="Email" required="" type="text" autocomplete="off"></td>
						</tr>
					</tbody>
				</table>
				
				<?php if(isset($_POST['email'])) { ?>
				<hr>
				<div style="color: #28a745; text-align: center;">Your pin was reseted. Check your email.(inbox or spam)</div>
				<?php } ?>
				
				<hr>
				<input type="submit" value="Reset pin" class="btn btn-success btn-lg btn-block" tabindex="7">
            </form>
        </div>
    </div>
</div>
</div>