-
Notifications
You must be signed in to change notification settings - Fork 1
/
add.php
166 lines (163 loc) · 6.71 KB
/
add.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
<?php
session_start();
include 'checkLogin.php';
include 'header.php';
$sql = "select * from employee";
$result = $conn->query($sql);
?>
<section class="vbox">
<header class="bg-dark dk header navbar navbar-fixed-top-xs">
<div class="navbar-header aside-md">
<a class="btn btn-link visible-xs" data-toggle="class:nav-off-screen,open" data-target="#nav,html">
<i class="fa fa-bars"></i>
</a>
<a href="#" class="navbar-brand" data-toggle="fullscreen">Employee </a>
<a class="btn btn-link visible-xs" data-toggle="dropdown" data-target=".nav-user">
<i class="fa fa-cog"></i>
</a>
</div>
<ul class="nav navbar-nav navbar-right m-n hidden-xs nav-user">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<span class="thumb-sm avatar pull-left">
<img src="images/avatar.jpg">
</span>
<?php if(isset($_SESSION['email'])){echo $_SESSION['email'];}?> <b class="caret"></b>
</a>
<ul class="dropdown-menu animated fadeInRight">
<li>
<a href="logout.php" >Logout</a>
</li>
</ul>
</li>
</ul>
</header>
<section>
<section class="hbox stretch">
<!-- .aside -->
<?php include 'left_bar.php';?>
<!-- /.aside -->
<section id="content">
<section class="vbox">
<section class="scrollable padder">
<div class="m-b-md">
<small>Welcome back, <?php echo $_SESSION['email'];?></small>
</div>
<div style="margin-top:1%;;color:green">
<?php if(isset($_REQUEST['msg'])){?>
<span class="errorSuccess" style="display: block;"><?php echo $_REQUEST['msg'];?></span>
<?php }?>
</div>
<div class="row">
<div class="col-sm-10">
<form data-validate="parsley" action="addemployee.php" method="POST">
<section class="panel panel-default">
<header class="panel-heading">
<span class="h4">Add an employee</span>
</header>
<div class="panel-body">
<p class="text-muted">Please fill the information to continue</p>
<div class="form-group">
<label>Employee First Name</label>
<input type="text" name="emp_first_name" id = "emp_first_name" class="form-control" required placeholder="First Name" data-required="true">
<span class="error" id = "emp_first_name_error"></span>
</div>
<div class="form-group">
<label>Employee Last Name</label>
<input type="text" name="emp_last_name" class="form-control" placeholder="Last Name" data-required="true">
</div>
<div class="form-group">
<label>Email</label>
<input type="text" name="emp_email" id = "emp_email" class="form-control" required data-type="email" placeholder="email" data-required="true">
<span class="error" id = "emp_email_error"></span>
</div>
<div class="form-group">
<label>Date of birth</label>
<input type="text" name="emp_dob" id = "emp_dob" class="input-sm input-s datepicker-input form-control" required data-date-format="yyyy-mm-dd" data-type="phone" placeholder="Date" data-required="true">
<span class="error" id = "emp_dob_error"></span>
</div>
<div class="form-group">
<label>Job Title</label>
<input type="text" name="emp_job_title" id = "emp_job_title" class="form-control" required data-type="phone" placeholder="Job Title" data-required="true">
<span class="error" id = "emp_job_title_error"></span>
</div>
<div class="form-group">
<label>Salary</label>
<input type="text" name="emp_salary" id = "emp_salary" class="form-control" required data-type="phone" placeholder="Salary" data-required="true">
<span class="error" id = "emp_salary_error"></span>
</div>
</div>
<footer class="panel-footer text-right bg-light lter">
<button type="submit" class="btn btn-success btn-s-xs" id="addEmployee">Add This Employee</button>
</footer>
</section>
</form>
</div>
</div>
</section>
</section>
<a href="#" class="hide nav-off-screen-block" data-toggle="class:nav-off-screen" data-target="#nav"></a>
</section>
</section>
</section>
</section>
<?php include 'footer.php';?>
<script>
$("#addEmployee").click(function(){
var f_name = $("#emp_first_name").val();
var email = $("#emp_email").val();
var dob = $("#emp_dob").val();
var job_title = $("#emp_job_title").val();
var salary = $("#emp_salary").val();
if(f_name==""){
$("#emp_first_name_error").text("Please enter first name.");
return false;
}else if(!isNaN(f_name)){
$("#emp_first_name_error").text("Please enter text only.");
return false;
}else{
$("#emp_first_name_error").text("");
}
if(email == ""){
$("#emp_email_error").text("Please enter email Id.");
return false;
}else if(!IsEmail(email)){
$("#emp_email_error").text("Please enter valid email Id.");
return false;
}else{
$("#emp_email_error").text("");
}
if(dob==""){
$("#emp_dob_error").text("Please select date of birth.");
return false;
}else{
$("#emp_dob_error").text("");
}
if(job_title==""){
$("#emp_job_title_error").text("Please enter job title.");
return false;
}else if(!isNaN(job_title)){
$("#emp_job_title_error").text("Please enter text only.");
return false;
}else{
$("#emp_job_title_error").text("");
}
if(salary==""){
$("#emp_salary_error").text("Please enter salary.");
return false;
}else if(isNaN(salary)){
$("#emp_salary_error").text("Please enter number only");
return false;
}else{
$("#emp_salary_error").text("");
}
function IsEmail(email) {
var regex = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/;
if(!regex.test(email)){
return false;
}else
return true;
}
});
$('.errorSuccess').delay(2000).fadeOut('slow');
</script>