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


$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=1&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/Khartoum');
$entry_date = date("Y-m-d H:i:s",time()-3600);

$table_name = $_SESSION['db_prefix']."_tracking_admin";
$action_query = "INSERT INTO $table_name (entry_date, user, action, details) VALUES ('".$entry_date."' ,'".$user_id."','New user' ,'".$username."' )";
execsql($action_query);




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



																  