<?php 
include 'inc/conx.php';
//echo gethostname() . php_uname('n');
//$pc = gethostname();
//$qpc = $db->query("SELECT * FROM admin");
//$rpc = $qpc->fetchArray();
//if($pc != $rpc['pc']){ echo 'You can not use this software. Please Contact : 03045464770 :)'; die();}

 
    if (isset($_POST['username'])) {
        # code...
        $username = $_POST['username'];
        $password = $_POST['password'];

        $sql = $db->query("SELECT count(*) AS rows FROM users WHERE name = '$username' AND pass = '$password'");
        $row = $sql->fetchArray();
        $rows = $row['rows'];

        if($rows > 0){
            $sql = $db->query("SELECT * FROM users WHERE name = '$username' AND pass = '$password'");
            while ($row = $sql->fetchArray())
            {
              echo $_SESSION['name'] = $row['name'];  
              echo "ID = ". $row['id'] . "\n";
              echo "Name = ". $row['name'] ."\n";
              echo "Password = ". $row['pass'] ."\n\n";

              $rights = explode(",", $row['rights']);
              foreach ($rights as $key => $value) {
                  echo $_SESSION[$value] = $value;
              }

              header("Location: dashboard.php");
            }
        }
    }
include 'header.php'; 
?>

    <div class="flip-container">
        <div class="flipper">
            <div class="front">
                <!-- front content -->
                <div class="holder" style="font-size: 16px;">
                                                                      

                    <div class="heading login-logo">
                        <img src="images/header_logo.png" alt="" />                    </div> 
                    <form action="" class="form login-form" id="loginform" autocomplete="off" method="post" accept-charset="utf-8">
            
                        <p>
									
Welcome to PHP Point of Sale system . To continue , use your username and password below , please login .

                                    <h2 class="text-center">Press login to continue</h2>								</p>
                        <input type="text" name="username" id="username" class="form-control" placeholder="Username" size="20" autocomplete="off"  />

                        <input type="password" name="password" id="password" class="form-control" placeholder="Password" size="20" autocomplete="off"  />
                
                        <div class="bottom_info">
                            <a href="resetpass.php" class="pull-right flip-link to-recover">Reset Password ?</a>
                            
                                                    </div>      
                        <div class="clearfix"></div>
                        <button type="submit" class="btn btn-primary btn-block">Login In</button>
                    </form>  
                    <div class="version">
                        <p>
                            <?php echo date("Y"); ?> Version <span class="badge bg-success">16.0</span>
                        </p>
								
                        								
                                            </div>                
                </div>
            </div>          
        </div>      
    </div>
<?php include 'footer.php'; ?> 