<?php
if (empty($_SESSION["admin"])) redirect("index.php?e=1");
//if ($_SESSION["user_type"]!=1) redirect("index.php?e=1");

if (!empty($_POST["btnSave"])) {
	
	$active=1;
	if (pdbfx("active")=='')
		$active=0;
	if ($_GET["user_id"]=='') //New item
	{

		$sql="Insert into user_master(first_name,last_name,active,email,user_name,password,user_type)";
		$sql.="values ('".pdbfx("first_name") ."','".pdbfx("last_name") ."',".$active .",'".pdbfx("email") ."','".pdbfx("user_name") ."','".pdbfx("password") ."',".pdbfx("user_type") .")";
		mysql_query($sql);
		
		$errMsg="<font color=red><b>User added</b></font>";
	}
	if ($_GET["user_id"]!='') //Edit Item
	{
		$sql="update user_master set first_name='".pdbfx("first_name") ."',last_name='".pdbfx("last_name")."',active=".$active .",email='".pdbfx("email") ."',user_name='".pdbfx("user_name") ."',password='".pdbfx("password") ."',user_type=".pdbfx("user_type") ." where user_id=".$_GET["user_id"];
		
		mysql_query($sql);
		$errMsg="<font color=red><b>User Information Saved.</b></font>";
	}
	echo("<script language='javascript' type='text/javascript'>");
	echo("window.opener.navigate(window.opener.document.location.href);");
	echo("</script>");

}

if ($_GET["user_id"]!='') //edit Category
{
$sql = "SELECT * from user_master where user_id=".$_GET["user_id"];

$cmd = mysql_query($sql);
$rs = mysql_fetch_array($cmd);	

}




?>
