<?session_start();
if(strlen($user)<=0)
{
 print "<script> alert('Invalid Login'); window.close();opener.document.location='ind.php';</script>";
 return;
}
print "User: $user <br> Branch: <font color=red>".$branch."<br><br>";
include("opendb.php");
$result=mysqli_query($db,"select * from bruser where userid='$code'") or die(mysqli_error());
$row=mysqli_fetch_array($result);
if($submit)
{
$dt=$yf.'-'.$mf.'-'.$df;
 $sql="update bruser set username='$username',level='$level',desig='$desig',addr='$addr',ph='$ph',pswd='$pswd1',utype='$utype',passdate='$dt' where userid='$code'";
print $sql;
mysqli_query($db,$sql) or die(mysqli_error());
print "<script>window.close(); opener.document.location='listuser.php';</script>";
}
?>
<script>
window.resizeTo(500,600);
</script>

<style>
td{font-family:'arial narrow';letter-spacing:1}
th{background-color:c1d799}
body{font-family:'arial narrow';letter-spacing:1;}
</style>

<link rel="stylesheet" href="style.css" type="text/css" />

<script>
function validate()
{
var p1=document.f1.pswd1.value
var p2=document.f1.pswd2.value

 submit="true";
 if(document.f1.username.value.length<3)
  {submit="false"; alert('Invalid User Name');}

 if(document.f1.pswd1.value.length<=0)
  {submit="false"; alert('Invalid Password');}

 if(document.f1.pswd2.value.length<=0)
  {submit="false"; alert('Invalid Password2');}
 if(p1!=p2)
  {submit="false"; alert('Passwords does not match');}

 if(submit=="false")
  return false;
}
</script>



<body bgcolor=fcfff1>
<font color=green size=4> <b>User Creation</font>
<hr bgcolor=red>
<center>
<form name='f1' action='<?print $PHP_SELF?>' method='post' onSubmit="return validate()">
<input type=hidden name='code' value='<?Print $row[0]?>'>
<table border=0  cellspacing=2 cellpadding=5>
<tr><td>User Name</td><td><input type=text readonly name='username' size=40 value='<?print $row[username]?>'></td></tr>
<tr><td>User Level</td><td><select name='level'>
<option><?print $row[level]?></option>
<option>0</option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>

</select>
</td></tr>

<tr><td>LedgerViewPswd</td><td><input type=text name='desig' size=40 value='<?print $row[desig]?>'></td></tr>
<tr><td>Address</td><td><input type=text name='addr' size=40 value='<?print $row[addr]?>'></td></tr>
<tr><td>Phone/Mobile</td><td><input type=text name='ph' size=40 value='<?print $row[ph]?>'></td></tr>
<tr><td>Password</td><td><input type=password name='pswd1' size=40 value='<?print $row[pswd]?>'></td></tr>
<tr><td>Confirm Password</td><td><input type=password name='pswd2' size=40 value='<?print $row[pswd]?>'></td></tr>
<td>
Date </td><td>dd<input type=text name='df' size=2 readonly value='<?print date('d',time())?>'>
	mm<input type=text name='mf' size=2 readonly value='<?print date('m',time())?>'>
	yy<input type=text name='yf' size=4 readonly value='<?print date('Y',time())?>'>
 </td></tr>
<tr><td>User Type</td><td><select name='utype'>
<option><?print $row[utype]?></option>
<option>active</option>
<option>in-active</option>
</select>
</td></tr>

<tr><td colspan=2 align=center><input type=submit name='submit' value='      Save      '> 
<input type=button value='     Cancel    ' onClick=window.close();>
</td></tr>
</table>
</form>
