<?php
include("../include/session.php");

date_default_timezone_set('Africa/Gaborone');
$entry_date = date("Y-m-d H:i:s", time()); 


$username = mysql_real_escape_string($_GET['user_name_text']);
$userpassword = mysql_real_escape_string($_GET['user_password_text']);


$table_name = $_SESSION['db_prefix']."_users";
$check_query = "SELECT username FROM $table_name WHERE username = '". $username."' ";
$check_result = execsql($check_query);
$check_num = mysql_num_rows($check_result);
if ($check_num!=0) { ?>
<script language="javascript" type="text/javascript">
          window.location="new_user.php?e=2&s=0";
</script>
<?php   
}
else { 
$userid = $username.$username;
$table_name = $_SESSION['db_prefix']."_users";
$user_query  = "INSERT INTO $table_name (username, password, userid, access_id) VALUES ('".$username."' ,'".md5($userpassword)."','".md5($userid)."'  ,'".md5($username)."')";
execsql($user_query);

$user_id = $_SESSION['username'];
date_default_timezone_set('Africa/Gaborone');
$entry_date = date("Y-m-d H:i:s", time()); 

$table_name = $_SESSION['db_prefix']."_tracking_admin";
$trackingQuery = "INSERT INTO $table_name (entry_date, user_name, action, details_1, details_2, details_3, details_4) VALUES ('".$entry_date."' ,'".$_SESSION['username']."', '121', '".$username."','','', '' )";
$trackingResult = mySQL_query($trackingQuery);




?>
<script language="javascript" type="text/javascript">
         window.location="user_list.php";
</script>
<?php
}
?>



																  