<?php session_start();
include("includes/db_config.php");
if(isset($_POST["login"])) 
{   extract($_POST); 
      //var_dump($_POST);exit();
$email = $_POST["email"]; 
$password = $_POST["password"]; 
$email = stripslashes($email);
$password = stripslashes($password);
$sql ="SELECT count(*) as num FROM user_profile WHERE email = '".$email."'";
$result = mysqli_query($conn, $sql) or die(mysqli_error($conn));
$res= mysqli_fetch_array($result);
$count=$res['num']; 
if($count > 0 )
{   $sql1 ="UPDATE  user_profile  SET password='$password'  WHERE email='$email' "; 
     $resss=mysqli_query($conn,$sql1) or die(mysqli_error());

echo '<script>alert("Password Updated successfully")</script>'; 
echo "<script>window.location.href='login.php'</script>";
}
else
{  echo '<script>alert("The Email Id is incorrect!")</script>'; 
}
} ?>
<!DOCTYPE html>
<html lang="en">
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content=" ">
    <meta name="author" content="">
    <title>Orange Groceries</title>
    <?php include("includes/css.php");?>
</head>

<body>
    <?php include("includes/header.php");?>
    <section class="shop-list section-padding">
        <div class="container">
            <div class="row">
                <div class="col-md-2 hidden-xs"></div>
                <div class="col-md-8 col-sm-8 col-xs-12">
                <div class="row" style="border: 1px solid #d4dbe0; border-radius:5px; box-shadow: 0 0 2px #ccc; background-color:#fff;">
                <div class="col-md-6 col-sm-6 col-xs-12 pl-0 ml-0">
				
				<img src="https://orangegroceries.com/img/login-banner.png" class="img-responsive">
				</div>
                <div class="col-md-6 col-sm-6 col-xs-12" >
                    <div class="mb-0">
                        <div class="row">
                            <div class="col-md-12">
                                <h2 class="text-center text-uppercase pt-20">Forgot Password</h2>
                            </div> 
                            <div class="signupbox-form form-logins" style="width:100%;">
                                <form class="login-form" method="POST" action="">
                                    <div class="form-group">
                                        <div class="col-md-12 col-xs-12 mb-15">
                                            <label style="font-size:15px;color:#000;">Email-Id</label>
                                            <input type="email" name="email"  class="form-control email-login" placeholder="Enter Email-Id" required="">
                                            <div class="alert alert-warning" id="result" style="display: none;"> </div>
                                        </div>
									 <div class="col-md-12 col-xs-12 mb-15">
                                           <label style="font-size:15px;margin-top:10px;color:#000;">Password</label>
                                             <input type="password"  id="chpassword" name="password" placeholder="Enter Password" onkeyup="checkPass()" class="form-control" required="">
                                        </div>
										
                                        <div class="col-md-12 col-xs-12 mb-15">
                                           <label style="font-size:15px;margin-top:10px;color:#000;">Confirm Password</label>
                                             <input type="password" onkeyup="checkPass()" id="cchpassword" name="password" placeholder="Enter Password" class="form-control" required="">
                                        </div>
                                    </div>
                                    
                                    <div class="clearfix"></div>
                                    <div class="col-md-12 col-xs-12 mb-15">
                                        <div class="dloginhide hidden">
                                            <div class="clearfix"></div>
                                           <div class="product_details_box product-add-to-cart-btn" style="margin-top:25px;">
											<a style="width:100%; text-align:center; font-size:16px;padding:0px;">
											 <input type="submit" name="login" value="Login Here" class="btn btn-lg btn-block inpt-control" style="background-color:#ed1d24;color:#fff;font-weight:600;" > <i class="mdi mdi-user" aria-hidden="true"></i>    
											</a>
										</div> 
                                            </div>
                                        </div> 
                                </form>
								<div class="col-md-12"> 
                                  <h6 class="text-center text-black" style="margin-top:2px;">Already Account?<a href="https://orangegroceries.com/login.php" style="color:#000;"> <strong>Login Here</strong></a></h6>  
                                <h6 class="text-center pt-5 text-black" style="margin-top:20px;">Don't have an account?<a href="https://orangegroceries.com/signup.php" style="color:#000;"> <strong>Create An Account</strong></a></h6>
                            </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <?php include("includes/footer.php");?>
    <?php include("includes/js.php");?>

   <!--  <script>
        jQuery(function() {
            jQuery('#in1').fastLiveFilter('#f1');
        });
    </script> -->
<script type="text/javascript">
        function checkPass()
    {
        var pass1 = document.getElementById('chpassword');
        var pass2 = document.getElementById('cchpassword');
        var message = document.getElementById('error-nwl');
        var goodColor = "#66cc66";
        var badColor = "#ff6666";
      
        if(pass1.value.length > 5)
        {
            pass1.style.backgroundColor = goodColor;
            message.style.color = goodColor;
            message.innerHTML = "character number ok!"
        }
        else
        {
            pass1.style.backgroundColor = badColor;
            message.style.color = badColor;
            message.innerHTML = " you have to enter at least 6 digit!"
            return;
        }
      
        if(pass1.value == pass2.value)
        {
            pass2.style.backgroundColor = goodColor;
            message.style.color = goodColor;
            message.innerHTML = "Password Match!"
        }
      else
        {
            pass2.style.backgroundColor = badColor;
            message.style.color = badColor;
            message.innerHTML = " These passwords don't match"
        }
    }  

 $(document).ready(function(){
    $(".email-login").keyup(function()
    {
    searchid = $(this).val();
    dataString = 'search='+ searchid;
    if(searchid!='')
    {
    $.ajax({
    type: "POST",
    url: "reg_validation.php",
    data: dataString,
    cache: false,
    success: function(html)
    {
    $("#result").html(html).show();
    }
    });
    }return false;
    });
    });
</script>
</body>
</html>