<?
/* Check User Script */
session_start();  // Start Session

include 'db.php';

// Convert to simple variables
$username = $_POST['username'];
$password = $_POST['password'];

if((!$username) || (!$password)){
   include 'langselect.php';
   echo "$lang0048 <br />";
	include 'loging.php';
	exit();
}

// Convert password to md5 hash
$password = md5($password);

// check if the user info validates the db
$sql = mysql_query("SELECT * FROM users WHERE username='$username' AND password='$password' AND activated='1'");
$login_check = mysql_num_rows($sql);

if($login_check > 0){
	while($row = mysql_fetch_array($sql)){
	foreach( $row AS $key => $val ){
		$$key = stripslashes( $val );
	}
		// Register some session variables!
		session_register('first_name');
		$_SESSION['first_name'] = $first_name;
		session_register('last_name');
		$_SESSION['last_name'] = $last_name;
		session_register('email_address');
		$_SESSION['email_address'] = $email_address;
		
		if ($first_name==Cli){
		header("Location: sample.php");
		} else {
		header("Location: sample2.php");
		}
		
		
	}
} else {
 include 'langselect.php';
	echo "$lang0047<br />";
	include 'loging.php';
}
?>