<?php
    include ('db.php');
	session_start();
    error_reporting(E_ALL & ~E_WARNING & ~E_NOTICE);
    if(isset($_POST['submit']))	{
        $mobile = $_POST['mobile'];	
        $pass = $_POST['passwrd'];
		$sql = "SELECT app_no,mobile, DATE_FORMAT(dob,'%d%m%Y') as dob FROM app_details WHERE mobile = '".$mobile."' and  DATE_FORMAT(dob,'%d%m%Y') = '".$pass."'";		
		// $resource =mysql_query($sql);			
		// $count = mysql_num_rows($resource);
        $resource =mysqli_query($link, $sql);			
		$count = mysqli_num_rows($resource);
		if($count>0){    
            // $row1 = mysql_fetch_assoc($resource);
            $row1 = mysqli_fetch_assoc($resource);
            if($row1['mobile'] != $mobile)
            {
                echo "<script>
                    alert('Invalid mobile no. Please enter your registered mobile no.');
                </script>";
            }
            else if($row1['dob'] != $pass)
            {
                echo "<script>
                    alert('Invalid password');
                </script>";
            }
            else{
                $appid = $row1['app_no'];
                // echo	$_SESSION['uid'] = $row1['app_no'];
                // echo	$_SESSION["lid"] = "1";
                // header('Location:/law-clerk-preview');
            }  
        }
        else {
            echo "<script>
                alert('Invalid login id & password');
            </script>";
        }
    }
?>
<!DOCTYPE html>
<html lang="en">
    <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> High Court Recruitment </title>
        <link id="favicon" rel="shortcut icon" type="image/png" href="images/fevicon.jpg" />
        <!-- <link href="lawclerk/css/styles.css" rel="stylesheet" /> -->
        <link href="css/styles.css" rel="stylesheet" />
        <script
            src="https://code.jquery.com/jquery-1.9.1.min.js" integrity="sha256-wS9gmOZBqsqWxgIVgA8Y9WcQOa7PgSIX+rPA0VL2rbQ=" crossorigin="anonymous"></script>
        <style>
            .head {
                background-color: #ffffff !important;
                border-bottom: 7px solid #1f537e;
            }
            .logo-name {
                font-size: 32px;
                color: #000;
                font-weight: 600;
                font-family: ui-sans-serif;
            }
        </style>
        
    <script type="text/javascript">
          $(document).ready(function () {

                $(".numeric").keypress(function (e) {
                    if (e.which != 8 && e.which != 0 && (e.which < 48 || e.which > 57)) {
                        $(".errmsg").html("Digits Only").show().fadeOut("slow");
                        return false;
                    }
                });
            });
        function fnLogin() {
            var uid = document.getElementById("mobile");
            var pass = document.getElementById("passwrd");
            if (uid.value == '') {
                alert("Please Enter 'Login ID'. ");
                uid.focus();
                return false;
            }
            else if (pass.value == '') {
                alert("Please Enter 'Password'. ");
                pass.focus();
                return false;
            }
            return true;
        }
    </script>
    </head>
    <body>
        <header>
            <div class="container col-lg-6" style="margin-top: 10px; margin-bottom: 10px;">
                <div class="row p-4 bg-light rounded-3">
                    <div class="col-lg-12">
                        <p class="fs-6 text-center">
                            <b>HIGH COURT OF MADHYA PRADESH : JABALPUR</b>
                            <br>
                            <b>LEGAL ASSISTANT/LAW CLERK-CUM-RESEARCH ASSISTANT EXAMINATION-2022-23</b>
                    </div>
                    <div class="section-header" style="text-align: center;">Registered candidates login to get application number</div>
                    <div class="col-lg-12" style = "border: thin solid #1f537e; margin-top: -5px;">
                    <!-- <form  name="class"  action="/forget-id-login" method="post">     -->
                    <form  name="class"  action="forget-id-login.php" method="post">    
                        <div class="form-group row top-pad">
                            <div class="col-sm-2"></div>
                            <div class="col-sm-8 pad-top">
                                <div caption"> Registered Mobile No. <span class="error">*</span></div>
                                <input type="text" name="mobile" id="mobile" placeholder="Registered Mobile No." value="" class="form-control" maxlength = "10" autocomplete="off">
                            </div>
                        </div>
                        <div class="form-group row top-pad">
                            <div class="col-sm-2"></div>
                            <div class="col-sm-8 pad-top">
                                <div caption"> Date of Birth (DDMMYYYY) <span class="error">*</span></div>
                                <input type="text" name="passwrd" id="passwrd"  class="form-control numeric" value="" maxlength="8" placeholder = "Date of Birth in DDMMYYYY" autocomplete="off">
                            </div>
                        </div>   
                        <div class="form-group row top-pad">
                            <div class="col-sm-2"></div>
                            <div class="col-sm-8 pad-top" style = "margin-bottom: 15px;">
                                <button id = "submit" name = "submit" onclick = "return fnLogin()" style = "width:100%" class="btn btn-info"> Login</button>
                            </div>
                        </div>   
                        <div class="form-group row top-pad">
                            <div class="col-sm-12" style = "text-align:center">                                
                                <?php 
                                    if($appid != null){
                                        echo "Your Application no. is ". $appid;
                                    }
                                ?>
                            </div>
                            <div class="col-sm-6"> 
                                <div style= "text-align:center">
                                    <a href = "https://mphc.gov.in/law-clerk-login" style = "text-decoration: none">Application Preview</a>
                                </div>
                            </div>
                            <div class="col-sm-6"> 
                                <div style = "text-align:center">
                                    <a href = "https://mphc.gov.in/lawclerk-admit-card-login"  style = "text-decoration: none">Admit Card Login</a>
                                </div>
                            </div>
                        </div> 
                            <br>
                    </form>                     
                    </div> 
                </div>
            </div>
        </header>
    </body>
</html>