<?php
	
			session_start();   

			include "database.php";
			DB_connexion(); 	
	 
			$var_login = $_GET['login'];
			$var_password = $_GET['pass'];

			$sql="SELECT * FROM membres WHERE login = '".$var_login."'";
			$result = mysql_query($sql);
			$count = mysql_num_rows($result);

			// login existe		
			if($count == 1)
			{
				$data = mysql_fetch_assoc($result);
	
				if($data['password'] != $var_password) 
				{
					// mauvais password
					echo "2";
				}
				else { 	
			
						if($data['statut_compte'] == "creation") 
						{  
							//compte inactif
							echo "3";	
						}
			
						else 
						{
								$sql="SELECT * FROM user_online WHERE login = '".$var_login."'";
								$result = mysql_query($sql);
								$val = mysql_fetch_array($result);
			
								if($val['connexion'] == "online")
								{	
									// utilisateur connecté 
									echo "4";
								}
								
								else
								{	
									// alors connexion
									$sql = "UPDATE user_online SET connexion = 'online' WHERE login = '".$var_login."' ";
									mysql_query($sql);
								
									$_SESSION['logged'] = "ok";
									$_SESSION['login'] = $data["login"];
									$_SESSION['user_id'] = $data["id"];
									
									$path = "Users/" .$_SESSION['login'];
									$_SESSION['repertoire']= $path;
									
									$tmp = $_SESSION['page_active'];
									$tab = explode(".", $tmp);
									$page = $tmp;
									echo '5*' .$page;
								}	
						}
					}
			}
			
			// le login n'existe pas
			else 
			{
				echo "1";
			}

?>