<?php

	if(isset($_POST['login']) && $_POST['login'] == 'Login') {
	
		include('./include/config.inc.php');
			mysql_select_db('account');
			
		$user = mysql_real_escape_string($_POST['user']);
		$pw = mysql_real_escape_string($_POST['pw']);
		
			$check = "SELECT * from account where login = '" . $user . "' and password = PASSWORD('$pw')";
				$query = mysql_query($check);
					$num = mysql_num_rows($query);
						
						
			if($num > 0) {
			
				$array = mysql_fetch_array($query);
				
				
			// SESSION variable start //
			
			$_SESSION['id'] = $array['login'];
			$_SESSION['coins'] = $array['coins'];
			$_SESSION['isadmin'] = $array['isadmin'];
			$_SESSION['pscadmin'] = $array['pscadmin'];
			$_SESSION['email'] = $array['email'];
			$_SESSION['real_name'] = $array['real_name'];
			$_SESSION['social_id'] = $array['social_id'];
            $_SESSION['user_admin'] = $array['web_admin']; 
			$_SESSION['user_id'] = $array['id'];
            $_SESSION['user_name'] = $array['login'];
            $_SESSION['user_coins'] = $array['coins'];
            $_SESSION['user_email'] = $array['email'];
			echo "<meta http-equiv='refresh' content='0; URL=index.php?s=home'>";
			} else {
			echo "<meta http-equiv='refresh' content='0; URL=index.php?s=conectare'>";
			}
		}
		
?>
<!-- center column -->
<div id="login" class="col-2">
	<div class="content content-last">
		<div class="content-bg">
			<div class="content-bg-bottom">
				<h2><?PHP echo $serverSettings['titel']; ?> - Entrar</h2>
				<div class="inner-form-border">
					<div class="inner-form-box">
						<h3><a id="topwLost" href="index.php?s=passwordlost" title="Ai uitat parola?">Perdistes la Contraceña?</a>Entrar</h3>
						<div class="trenner"></div>
						<form name="loginForm" id="loginForm" action="index.php?s=login" method="post">
							<div>
								<label for="username">Nombre de la Cuenta: *</label>
								<input AUTOCOMPLETE="off" type="text" class="validate[required,custom[noSpecialCharacters],length[3,16]]" id="username" name="user" maxlength="16" value=""/>
							</div>
							<div>
								<label for="password">Contraceña: *</label>
								<input AUTOCOMPLETE="off" type="password" class="validate[required,length[5,16]]" id="password" name="pw" maxlength="16" value=""/>
							</div>
							<div id="checkerror">
                            <p>Si tienes algun tipo de problema o pregunta contacta con nuestro soporte!</p>
							</div> 
							
							<input id="submitBtn"class="btn-big" type="submit" name="login" value="Login"/>
							<script type="text/javascript">
							</script>
						</form>			
						<p id="regLegend">* todos los datos son necesarios</p>
						<div class="trenner"></div>
						<div id="subscribe">
							<h3><br>No tienes cuenta?</h3>
							<p>Crea una cuenta en Land of Metin totalmente gratis para comenzar la aventura!</p>
							<a class="btn-big" href="index.php?s=register" title="Crează un cont">Entra aqui!</a>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>