<?php
session_start();

require ("../global.php");
InitGP(array('name','pw','num_check'),'P');

if (!empty($name) && !empty($pw)) {

	$_SESSION['num_check'] != $num_check &&  Showmsg("num_check_err");
	empty_chk(array($name,$pw));
	str_filter(array($name,$pw),'chk');
	
	$sql = "select * from ".$db_tablepre."user INNER JOIN   ".$db_tablepre."admin ON ".$db_tablepre."admin.u_id=".$db_tablepre."user.u_id WHERE ".$db_tablepre."user.u_name='".$name."' and ".$db_tablepre."user.u_password='".md5($pw)."'";
	$query = sql_return($sql,2);
	if (!empty($query)) {

		$_SESSION['admin_name'] = $query['u_name'] ;
		$_SESSION['admin_groupid'] = $query['groupid'];
		$_SESSION['admin_a_id'] = $query['a_id'];
		$_SESSION['admin_u_id'] = $query['u_id'];
		$admin_login = 'login';
	}else Showmsg('log_err_1');

}



elseif (!empty($_SESSION['admin_name'])) {
	$admin_login = 'login';
}


require PrintEot($self_template,'A');

?>