<commit_before><?php
//session_start();



//DB configuration Constants

require_once "../php/db_connect.php";
$databaseConnection =connect_to_db();
echo
"<script>
$(function() {
    if (localStorage.chkbx && localStorage.chkbx != '') {
        $('#remember_me').attr('checked', 'checked');
        $('#login').val(localStorage.usrname);
        $('#password').val(localStorage.password);


    } else {
        $('#remember_me').removeAttr('checked');
        $('#login').val('<EMAIL>');
        $('#password').val('<PASSWORD>');
    }

    $('#remember_me').click(function() {

        if ($('#remember_me').is(':checked')) {
            // save username and password
            localStorage.usrname = $('#login').val();
            localStorage.password = $('#password').<PASSWORD>();
            localStorage.chkbx = $('#remember_me').val();
        } else {
            localStorage.usrname = '<EMAIL>';
            localStorage.password = '<PASSWORD>';
            localStorage.chkbx = '';
        }
    });
});
</script>";



if(!empty($_POST['username'])){
    $errMsg = '';

    //username and password sent from Form
    $username = trim($_POST['username']);
    $password = md5(trim($_POST['password']));

    if($username == '<EMAIL>')
        $errMsg .= 'You must enter your Username<br>';

    if($password == '<PASSWORD>')
        $errMsg .= 'You must enter your Password<br>';

    if($errMsg == '')
    {
        $records = $databaseConnection->prepare('SELECT id,username,password FROM  company WHERE username = :username');
        $records->bindParam(':username', $username);
        $records->execute();
        $results = $records->fetch(PDO::FETCH_ASSOC);
        //if(count($results) > 0 && password_verify($password, $results['password'])){
        /*if(count($results) > 0 && $password === $results['password'] )
        {
            $_SESSION['username'] = $results['username'];
            header('location: ../#/main');
            exit;
        }else{
            $errMsg .= 'Username and Password are not found<br>';
            header('location: ../#/login');
            exit;
        }
*/

        if(count($results) > 0 && $password === $results['password'] )
        {

            //$_SESSION['username'] = $username;
            echo("<a id='re_route_main' href ='../#/main'></a>
                 <script>                  
                    sessionStorage.setItem('username', '".$username."');
                    document.getElementById(\"re_route_main\").click();
                </script>
                ");
            exit;
        }
        else
        {
            $errMsg .= 'Username and Password are not found<br>';
            echo("<a id='re_route_login' href ='../#/login'></a>
                <script>
                    alert('Wrong Password Or User Name.');
                    document.getElementById(\"re_route_login\").click();
                </script>
            ");
            exit;
        }
    }
}
?>
<commit_msg>Remember me - with local storage<commit_after><?php
//session_start();



//DB configuration Constants

require_once "../php/db_connect.php";
$databaseConnection =connect_to_db();
echo
"<script>
localStorage.clear();
$(function() {
    if (localStorage.chkbx && localStorage.chkbx != '') {
        $('#remember_me').attr('checked', 'checked');
        $('#login').val(localStorage.usrname);
        $('#password').val(localStorage.password);


    } else {
        $('#remember_me').removeAttr('checked');
        $('#login').val('<EMAIL>');
        $('#password').val('<PASSWORD>');
    }

    $('#remember_me').click(function() {

        if ($('#remember_me').is(':checked')) {
            // save username and password
            localStorage.usrname = $('#login').val();
            localStorage.password = $('#password').val();
            localStorage.chkbx = $('#remember_me').val();
        } else {
            localStorage.usrname = '<EMAIL>';
            localStorage.password = '<PASSWORD>';
            localStorage.chkbx = '';
        }
    });
});
</script>";



if(!empty($_POST['username'])){
    $errMsg = '';

    //username and password sent from Form
    $username = trim($_POST['username']);
    $password = <PASSWORD>(trim($_POST['password']));

    if($username == '<EMAIL>')
        $errMsg .= 'You must enter your Username<br>';

    if($password == '<PASSWORD>')
        $errMsg .= 'You must enter your Password<br>';

    if($errMsg == '')
    {
        $records = $databaseConnection->prepare('SELECT id,username,password FROM  company WHERE username = :username');
        $records->bindParam(':username', $username);
        $records->execute();
        $results = $records->fetch(PDO::FETCH_ASSOC);
        //if(count($results) > 0 && password_verify($password, $results['password'])){
        /*if(count($results) > 0 && $password === $results['password'] )
        {
            $_SESSION['username'] = $results['username'];
            header('location: ../#/main');
            exit;
        }else{
            $errMsg .= 'Username and Password are not found<br>';
            header('location: ../#/login');
            exit;
        }
*/

        if(count($results) > 0 && $password === $results['password'] )
        {

            //$_SESSION['username'] = $username;
            echo("<a id='re_route_main' href ='../#/main'></a>
                 <script>                  
                    sessionStorage.setItem('username', '".$username."');
                    document.getElementById(\"re_route_main\").click();
                </script>
                ");
            exit;
        }
        else
        {
            $errMsg .= 'Username and Password are not found<br>';
            echo("<a id='re_route_login' href ='../#/login'></a>
                <script>
                    alert('Wrong Password Or User Name.');
                    document.getElementById(\"re_route_login\").click();
                </script>
            ");
            exit;
        }
    }
}
?>

{'fraction_non_alphanumeric': 0.1854890604890605, 'fraction_numerical': 0.0011261261261261261, 'mean_word_length': 1.8362226277372262, 'pattern_counts': {'":': 0, '<': 47, '<?xml version=': 0, '>': 61, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '101194', 'n_tokens_mistral': 1769, 'n_tokens_neox': 1656, 'n_words': 297}