Current File : /home/obabain/ms_obaba_in/AddUser.jsp |
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ include file="Connection.jsp" %>
<%
Statement st=con.createStatement();
%>
<%!
String depid;
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<script src="http://code.jquery.com/jquery-latest.min.js"
type="text/javascript"></script>
<title>User</title>
</head>
<body>
<script>
function checkExist(){
var xmlhttp = new XMLHttpRequest();
var username = document.forms["po"]["logname"].value;
var url = "exist.jsp?username=" + username;
xmlhttp.onreadystatechange = function(){
if(xmlhttp.readyState == 4 && xmlhttp.status == 200){
if(xmlhttp.responseText == "User already exists")
document.getElementById("isE").style.color = "red";
else
document.getElementById("isE").style.color = "green";
document.getElementById("isE").innerHTML = xmlhttp.responseText;
}
};
xmlhttp.open("GET",url,true);
xmlhttp.send();
}
</script>
<form method="post" name="po">
<%@include file="master.jsp" %>
<div class="content">
<div class="row" style="width:110%">
<div class="col-md-9" style="background-color:white;">
<div class="panel panel-default" >
<div class="panel-heading main-color-bg">
<h3 class="panel-title">Add User</h3>
</div>
</div>
<div class="headerbar-item pull-right">
<a href="ViewUserAdmin.jsp" style="background:#204b58" class="btn btn-info">View User</a>
</div>
<div class="row">
<div class="form-group col-xs-3">
<div class="onerow">
Login Name<span style="color:red;">*</span>
<input type="text" name="logname" id="logname" class="form-control input-group-lg reg_name" style="width:200px;margin:5px;" onblur="checkExist()">
<span id="isE"></span>
</div>
</div>
<div class="form-group col-xs-3">
<div class="onerow">
Password<span style="color:red;">*</span>
<input type="password" name="password" id="password" class="form-control input-group-lg reg_name" style="width:200px;margin:5px;">
</div>
</div>
<div class="form-group col-xs-3">
<div class="onerow">
Confirm Password<span style="color:red;">*</span>
<input type="password" name="confpass" id="confpass" class="form-control input-group-lg reg_name" style="width:200px;margin:5px;">
</div>
</div>
</div>
<div class="row">
<div class="form-group col-xs-3">
<div class="onerow">
First name
<input type="text" name="fname" class="form-control input-group-lg reg_name" style="width:200px;margin:5px;">
</div>
</div>
<div class="form-group col-xs-3">
<div class="onerow">
Last name
<input type="text" name="lname" class="form-control input-group-lg reg_name" style="width:200px;margin:5px;">
</div>
</div>
<div class="form-group col-xs-3">
<div class="onerow">
Email
<input type="text" name="email" class="form-control input-group-lg reg_name" style="width:200px;margin:5px;">
</div>
</div>
</div>
<div class="row">
<div class="form-group col-xs-3">
<div class="onerow">
Company
<select class="form-control input-group-lg reg_name" name="company" style="width:200px;margin:5px;">
<option value="0">-select-</option>
<%
ResultSet rc=st.executeQuery("select * from ip_users");
while(rc.next())
{
%>
<option value="<%=rc.getString("user_id")%>"><%=rc.getString("user_name")%></option>
<%} %>
</select>
</div>
</div>
<div class="form-group col-xs-3">
<div class="onerow">
Department
<select class="form-control input-group-lg reg_name" name="dept" style="width:200px;margin:5px;">
<option value="0">-select-</option>
<%
ResultSet rd=st.executeQuery("select * from ip_department");
while(rd.next())
{
depid=rd.getString("id");
%>
<option value="<%=rd.getString("id")%>"><%=rd.getString("dept_name")%></option>
<%} %>
</select>
<!--
<button style="width:200px;margin:5px;">Select</button>
-->
</div>
</div>
<div class="form-group col-xs-3">
<div class="onerow">
User Role
<select class="form-control input-group-lg reg_name" name="role" style="width:200px;margin:5px;">
<option value="0">-select-</option>
<%
ResultSet rs=st.executeQuery("select * from ip_dept_roles");
while(rs.next())
{
%>
<option value="<%=rs.getString("id") %>"><%=rs.getString("role") %></option>
<%} %>
</select>
</div>
</div>
<!--
<div class="form-group col-xs-3">
<div class="onerow">
Email Signature
<textarea name="emailsign" class="form-control input-group-lg reg_name" style="width:250px;margin:5px;height:100px;"></textarea>
</div>
</div>
-->
</div>
<!--
<div class="row">
<div class="form-group col-xs-3">
<div class="onerow">
Inform new User?
<input type="checkbox" name="chk">
</div>
</div>
</div>
-->
<div class="modal-footer" id="contact_submit">
<a class="btn btn-default" href="AddUser.jsp">Reset</a>
<button type="submit" style="background:#204b58" class="btn btn-info" >Save Changes</button>
</div>
</div>
<!--
<div class="col-md-2" style="margin-top:10px; ">
<input type="submit" value="submit" class="btn btn-success" onclick="confirmpass()">
<a class="btn btn-primary" href="ViewUserAdmin.jsp">View Users</a>
<a class="btn btn-danger" href="AddUser.jsp">Reset</a>
</div>
-->
<%
try{
String uname=request.getParameter("logname");
String pass=request.getParameter("password");
String role=request.getParameter("role");
String fname=request.getParameter("fname");
String lname=request.getParameter("lname");
String comp=request.getParameter("company");
String dept=request.getParameter("dept");
String email=request.getParameter("email");
String esign=request.getParameter("emailsign");
ResultSet r=st.executeQuery("select uname from login where uname='"+uname+"'");
if(r.next())
{
}
else
{
if((uname.length()!=0 ||uname!="") && (pass.length()!=0 || pass!=""))
{
int i=st.executeUpdate("insert into login values(0,'"+uname+"','"+pass+"',0,"+role+",'"+fname+"','"+lname+"','"+comp+"','"+dept+"','"+email+"','',"+loginid+",NOW())");
}
}
}
catch(Exception el){}
%>
</div>
</div>
<%@include file="footer.jsp" %>
</form>
<script type="text/javascript">
function confirmpass()
{
var a=document.getElementById("password").value;
var b=document.getElementById("confpass").value;
var c=document.getElementById("logname").value;
//alert(a);
if(a!=b)
alert('Password Mismatch');
if(a==null ||a=="" ||b==null ||b=="" ||c==null ||c=="" )
alert('Fill all mandatory fields')
//else
//alert('Saved Suucessfully')
};
</script>
</body>
</html>