Location: PHPKode > projects > CoreAsset > coreasset/add_user.php
<?php
require_once("lib/inc.php");
require_once("lib/security.php");

$smarty = new Smarty;
$smarty->compile_check = true;
$smarty->debugging = false;
$title	  ="::: Add User :::";
$smarty->assign('title',$title);

$date     = date("Y-m-d");
$status   = $_SESSION['status'];
$user_id  = $_SESSION['user_id'];
$smarty->assign('user_id',$user_id);
$row      = $database->get_from_database("select * from asset_users where user_id='$user_id'");
$name     = $row['full_name'];
$rw		  = $database->get_from_database("select * from asset_users where user_id='$_SESSION[user_id]'");
$last_login  = $rw['last_login'];
$last_logout = $rw['last_logout'];
$smarty->assign('last_login',$last_login);
$smarty->assign('last_logout',$last_logout);

// Date & Time to be dispalyed on the header 
$date_time	= date("h:i:s A")." ".date("d-m-Y");
$smarty->assign('date_time',$date_time);
// Done
if($status < 4)
{
  if(isset($_GET['act']))
  {
   if($_GET['act']=="add")
   {
    $login                = $_POST['login'];
    $password             = base64_encode($_POST['password']);
    $full_name            = $_POST['full_name'];
    $email                = $_POST['email'];
    $snd_email            = $_POST['snd_email'];
	$comments			  = $_POST['comments'];
    $status1              = $_POST['status'];

    $numb                 = $database->no_of_rows("select * from asset_users where login='$login'");
    if($numb==0)
    {
      if($database->insert("insert into asset_users (login, password, full_name, email, status, comments, created_on, created_by) values ('$login', '$password', '$full_name', '$email', '$status1', '$comments', '$date','$user_id')"))
	  {
		$acc_type = "";
		$subject 	= "Account Information";
		$to			= $email;
	//	$from		= "CSPL Asset Management System";
		if($status1==1)
		{
			$acc_type = "Administrator";
		}
		if($status1==2)
		{
			$acc_type = "Supervisor";
		}
		if($status1==4)
		{
			$acc_type = "Reader";
		}

		
		$message	= "Congratulation !! You are new user of Core Asset. Your Account infomaion is as follows :
		
		User ID 	: ".$login."
		Password 	: ".base64_decode($password)."
		User Type   : ".$acc_type."

		----
		Regarding
		Corelynx Inc.";
			
			if($snd_email=="Y")
			{
				@mail($to, $subject, $message, "From: CSPL Asset Management System"); 	  
			}
			else
			{
			}
			
			redirect ("manage_admin.php","Add");
		 }
    }
    else
    {
      redirect ("manage_admin.php","Exist");
    }
   }
  }
}
else
{
 $mes = "Sorry ! You have no such Privillage ...";
 $smarty->assign('mes',$mes);
}
$smarty->assign('name',$name);
$smarty->assign('status',$status);



$smarty->display('add_user.tpl');
?>
Return current item: CoreAsset