<?php

//include ("dbset.php");

$username = $_POST['user_name_text'];
$password = $_POST['password_text'];

// Include database connection settings
//include("db.php");

$con = mysql_connect("localhost","web15u2","sHK3od6a");
if (!$con)
  {
  die('Could not connect to database: ' . mysql_error());
  }
   
mysql_select_db('web15db2', $con);

function execsql($qry){
	$result = mysql_query($qry);
	return $result;
}




$login_query = "SELECT username FROM users WHERE username = '" . $username . "' AND password = '" . (md5($password)) . "' ";
$login_result = mySQL_query($login_query);
$num = mysql_num_rows($login_result);

// Check username and password match
if ($num == 1) {
// Inialize session
session_start();	
//include('log_in_check.php');
//// Set username session variable
//
//$access = "SELECT access_id, home_page FROM af_users WHERE (username = '" .$username. "') ";
////echo $access;
//$accessResult = mySQL_query($access);
//$_SESSION['access_id'] = mysql_result($accessResult, 0, "access_id");
//$home_page = mysql_result($accessResult, 0, "home_page");
//$_SESSION['username'] = $_POST['user_name_text'];
////echo "home:".$home_page;
//date_default_timezone_set('Africa/Khartoum');
//$entry_date = date("Y-m-d H:i:s",time()-1620);  
//
//$active_query = "INSERT INTO active_users (username) VALUES ('".$_SESSION['username']."' ) ";
//execsql($active_query);
////echo $active_query."<br>";
//
//
//
//if ($home_page=="production") {$location = "production/production_main.php?period=day"; }
//if ($home_page=="stores") {$location = "store/store_main.php?period=day"; }
//if ($home_page=="sales") {$location = "sales/sales_main.php?period=day"; }
//if ($home_page=="transport") {$location = "transport/transport_main.php?period=day"; }
//if ($home_page=="admin") {$location = "admin_module/user_list.php";  }
//if ($home_page=="") {$location = "login.php?e=2"; }
//$_SESSION['location'] = $location;

// Jump to secured page
  header('Location: ../mainmenu.php' );
}
else {
//Jump to login page
    header('Location: ../login.php?e=1');
}

?>