<?php
	session_start();

	$usercode = $_POST['au1'];
	$usernameth = $_POST['au2'];
	$userlnameth = $_POST['au3'];
	$usernameen = $_POST['au4'];
	$userlnameen = $_POST['au5'];
	//$p = $_POST['au6'];
	//$p = $_POST['au7'];
	$usersex = $_POST['au67'];
	$userposition = $_POST['au8'];
	$userdepartment = $_POST['au9'];
	$usercompany = $_POST['au10'];
	$userbranch = $_POST['au11'];
	$userloginname = $_POST['au12'];
	$userpassword = $_POST['au13'];

	$userlogin = $_SESSION['userloginname'];

	//echo "{$usercode},{$usernameth},{$userlnameth},{$usernameen},{$userlnameen},{$usersex},{$userposition},{$userdepartment},{$usercompany},{$userbranch},{$userloginname},{$userpassword}";

	include "../../../Connections/connect_mysql.php";
	//mysql_query("set names utf8");

	$sql_s = "SELECT * FROM position_tb where poscode='{$poscode}' ";
	$result_s = mysql_query($sql_s) or die(mysql_error());
	if (mysql_num_rows($result_s)==0){
		$sql = " INSERT INTO user_tb (usercode, usernameth, userlnameth, usernameen, userlnameen, usersex, userposition, userdepartment, usercompany, userbranch, userloginname, userpassword, userpin, userpicpath, createby, createtime, updateby, updatetime, statustrans, statonline, lasttimeonline, remark)"; 
		$sql .=  " VALUES ('{$usercode}', '{$usernameth}', '{$userlnameth}', '{$usernameen}', '{$userlnameen}', '{$usersex}', {$userposition}, {$userdepartment}, {$usercompany}, {$userbranch}, '{$userloginname}', '{$userpassword}', '-', '-', '{$userlogin}', NOW(), '{$userlogin}', NOW(), 'N', 'N', NOW(), '-')";

		$result = mysql_query($sql) or die(mysql_error());

		echo "Y";

	}else{

		echo "N";
	}



	mysql_close($c);


 ?>
