<?
session_start();
include "../inc/db.php";
if(isset($_POST['submit'])){
	if($_POST['username']==NULL || $_POST['parola']==NULL)
		$eroare = "Wrong Username/Password!";
	else{
		$res	= mysql_query("select (Select value from config where name='admin_pass') as admin_pass,(Select value from config where name='admin_user') as admin_user ")or die('Mysql Error:'.mysql_error());
		$row    = mysql_fetch_array($res);

		if($_POST['username']!=$row['admin_user'] || $_POST['parola']!=$row['admin_pass'])
			$eroare = "Wrong Username/Password!";

		if(empty($eroare)){
			$_SESSION['log_mobile']=1;
			header("Location: index.php"); 
		}
	}
}
?>
<!DOCTYPE HTML>
<html>
    <head>
        <title>Login - Pro invoice maker</title>
		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
        <link rel="stylesheet" href="css/font-awesome.min.css" />
        <link rel="stylesheet" href="css/jquerymobile.css" />
        <link rel="stylesheet" href="css/jquerymobile.nativedroid.css" />
        <link rel="stylesheet" href="css/jquerymobile.nativedroid.light.css"  id='jQMnDTheme' />
        <link rel="stylesheet" href="css/jquerymobile.nativedroid.color.blue.css" id='jQMnDColor' />
		<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
        <script src="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.js"></script>


    </head>
    <body>
        
    <div data-role="page" data-theme='b'>

        <div data-role="header" data-position="fixed" data-tap-toggle="false" data-theme='b'>
            <h1>Pro Invoice Maker 2.0</h1>
            <a href="http://nativedroid.godesign.ch/" data-ajax='false' target='_blank'><i class='icon-briefcase'></i></a>
        </div>
        
        <div data-role="content">   
		<?if($eroare){?>
		<div class='message error'>
			<i class='icon-exclamation-circle'></i>
			<p><?=$eroare?></p>
		</div>		
		<?}?>
		<form action='' method='post'>
                <ul data-role="listview" data-inset="true">
					<li data-role="fieldcontain">
                        <label for="name2b">Username:</label>
                        <input type="text" name="username" id="name2b" value="<?=$_POST['username']?>" data-clear-btn="true" placeholder="Type here...">
                    </li>					
					<li data-role="fieldcontain">
                        <label for="name2b">Password:</label>
                        <input type="password" name="parola" id="name" value="" data-clear-btn="true" placeholder="">
                    </li>
	                    <li>
                        <fieldset class="ui-grid-a">
                                <div class="ui-block-a"><button type="submit" data-theme="b">Cancel</button></div>
                                <div class="ui-block-b"><button type="submit" name='submit' data-theme="b">Submit</button></div>
                        </fieldset>
                    </li>				
			</ul>
			</form>
        </div>

    </div>
    
    </body>
</html>
