Login Form:
<?php
if(isset($_POST['btnlogin']))
{
$A = mysql_connect("LocalHost","root","") or die("Error in MYSQL Connection");
mysql_select_db("payroldb",$A) or die("Error in Data Base");
$NM = $_POST['txtName'];
$RN = $_POST['txtRegno'];
$query = mysql_query("SELECT * FROM tblemp where FirstName='".$NM."' AND RegNo='".$RN."'", $A) or die("Error in Select Query");
$row = mysql_fetch_array($query);
if($row["FirstName"]==$NM && $row["RegNo"]==$RN)
{
echo "<script> window.location.assign('index.php'); </script>";
echo "<a href='index.php?A=$rec[1] &B=$rec[3]></a></td>";
}
else
{
echo "<script>";
echo 'alert("Your Name OR Reg No is wrong...!")';
echo"</script>";
}
mysql_close($A);
}
?>
<div class="login-header text-center">
<br><br>
<img src="assets/img/team-back1.jpg">
</div>
<div class="login-wrapper">
<form action="login.php" method="post">
<div class="form-group has-feedback lg left-feedback no-label">
<input type="text" name="txtName" placeholder="Enter FirstName" autofocus required>
<span class="fa fa-user form-control-feedback"></span>
</div>
<div class="form-group has-feedback lg left-feedback no-label">
<input type="password" name="txtRegno" placeholder="Enter Reg.No" required>
<span class="fa fa-unlock-alt form-control-feedback"></span>
</div>
<div class="form-group">
</div>
<div class="form-group">
<button type="submit" name="btnlogin" >LOGIN</button>
</div>
</form>
</div><!-- /.login-wrapper -->
Add Employee:
<?php
if(isset($_POST['btnReg']))
{
$NM = $_POST['txtName'];
$LN = $_POST['txtLName'];
$UI = $_FILES['UImg']['name'];
$FT = $_FILES['UImg']['type'];
$FN = $_POST['txtFName'];
$CC = $_POST['txtNIC'];
$PN = $_POST['telno'];
$AD = $_POST['txtadres'];
$DB = $_POST['DOB'];
$GN = $_POST['rdoGend'];
$JD = $_POST['JDate'];
$RL = $_POST['lstRlgn'];
$DG = $_POST['txtDesg'];
$DP = $_POST['lstDept'];
$ST = $_POST['txtStatus'];
$RN = $_POST['txtRegno'];
if($FT =="image/jpeg" || $FT == "image/gif" || $FT=="image/png")
{
$A = mysql_connect("LocalHost","root","") or die("Error in MYSQL Connection");
mysql_select_db("payroldb",$A) or die("Error in Data Base");
mysql_query("Insert into tblemp values ('','$NM','$LN','$UI','$FN','$CC','$PN','$AD','$DB','$GN','$JD','$RL','$DG','$DP','$ST','$RN')", $A) or die("Error in Insert Query");
mysql_close($A);
echo '<script language="javascript">';
echo 'alert("Registered Successfuly...!")';
echo '</script>';
}
else
{
echo "Error: Select jpg | gif | png image.";
}
}
?>
<p>Begin your Registration here</p>
<!-- Begin basic form elements -->
<div class="row">
<div class="col-sm-6">
<!-- Begin basic form elements -->
<div class="the-box">
<h4 class="small-title">Employee's Information</h4>
<form action="add-emp.php" method="POST" Enctype="multipart/form-data">
<div class="form-group">
<label>First Name</label>
<input type="text" name="txtName" class="form-control rounded" placeholder="Enter First Name" required>
</div>
<div class="form-group">
<label>Last Name</label>
<input type="text" name="txtLName" class="form-control rounded" placeholder="Enter Last Name" required>
</div>
<div class="form-group">
<label>Upload Image</label>
<div class="input-group">
<input type="file" name="UImg" required>
</div><!-- /.input-group -->
</div>
<div class="form-group">
<label>Father Name</label>
<input type="text" name="txtFName" class="form-control rounded" placeholder="Enter Father Name" required>
</div>
<div class="form-group">
<label>NIC No</label>
<input type="text" name="txtNIC" class="form-control rounded" placeholder="Enter NIC No" required>
</div>
<div class="form-group">
<label>Phone No</label>
<input type="text" name="telno" class="form-control rounded" placeholder="Enter Phone No" required>
</div>
<div class="form-group">
<label>Address</label>
<textarea name="txtadres" class="form-control rounded no-resize bold-border" required></textarea>
</div>
<div class="form-group">
<label>Date of Birth</label>
<input type="date" name="DOB" class="form-control rounded" data-date-format="mm-dd-yy" placeholder="mm-dd-yy" required>
</div>
<div class="form-group">
<label>Gender</label>
<div class="radio">
<label>
<input type="radio" name="rdoGend" id="optionsRadios1" value="Male" checked>
Male
</label>
</div>
<div class="radio">
<label>
<input type="radio" name="rdoGend" id="optionsRadios2" value="Female">
Female
</label>
</div>
</div>
<div class="form-group">
<label>Joining Date</label>
<input type="date" name="JDate" class="form-control rounded" data-date-format="mm-dd-yy" placeholder="mm-dd-yy" required>
</div>
<div class="form-group">
<label>Religion</label>
<select name="lstRlgn" class="form-control rounded">
<option value="Islam">Islam</option>
<option value="Baha’i Faith">Baha’i Faith</option>
<option value="Buddhism">Buddhism</option>
<option value="Christianity">Christianity</option>
<option value="Confucianism">Confucianism</option>
<option value="Hinduism">Hinduism</option>
<option value="Jainism">Jainism</option>
<option value="Judaism">Judaism</option>
<option value="Shinto">Shinto</option>
<option value="Sikhism">Sikhism</option>
<option value="Taoism">Taoism</option>
<option value="Zoroastrianism">Zoroastrianism</option>
<option value="Other">Other</option>
</select>
</div>
<div class="form-group">
<label>Designation</label>
<input type="text" name="txtDesg" class="form-control rounded" placeholder="Enter Designation" required>
</div>
<div class="form-group">
<label>Department</label>
<select name="lstDept" class="form-control rounded">
<option value="Customer Services">Customer Services</option>
<option value="Financial">Financial</option>
<option value="Human Resources">Human Resources</option>
<option value="Information Technology">Information Technology</option>
<option value="Inventory">Inventory</option>
<option value="Insuarence">Insuarence</option>
<option value="Licences">Licences</option>
<option value="Marketing">Marketing</option>
<option value="Operational">Operational</option>
<option value="Organizational">Organizational</option>
<option value="Purchasing">Purchasing</option>
<option value="Quality Asuarence">Quality Asuarence</option> <option value="Sales">Sales</option>
<option value="Staff">Staff</option>
<option value="Other Services">Other Services</option>
</select>
</div>
<div class="form-group">
<label>Working Status</label>
<input type="text" name="txtStatus" class="form-control rounded" placeholder="Enter Working Status" required>
</div>
<div class="form-group">
<label>Registration No</label>
<input type="text" name="txtRegno" class="form-control rounded" placeholder="Enter Registration No" required>
</div>
<div class="form-group">
<input class="btn btn-primary" type="submit" name="btnReg" value="Register">
</div>
</form>
</div><!-- /.the-box -->
<!-- End basic form elements -->
</div>
Search Employee:
<form method="get" action="Search-Emp.php" class="navbar-form navbar-left" role="search">
<div class="form-group">
<input type="text" name="name" class="form-control" placeholder="Enter First Name">
<input type="submit" name="submit" value="Search">
</div>
</form>
<br><br><br>
<!-- Begin basic form elements -->
<div class="row">
<div class="col-sm-6">
<table border=1>
<tr bgcolor="#CC99CC">
<th>Emp ID</th>
<th>First Name</th>
<th>Last Name</th>
<th>Image</th>
<th>Father Name</th>
<th>NIC</th>
<th>Phone Number</th>
<th>Address</th>
<th>Date Of Birth</th>
<th>Gender</th>
<th>Joining Date</th>
<th>Religion</th>
<th>Designation</th>
<th>Department</th>
<th>Working Status</th>
<th>Reg.No</th>
<th>Salary Slip</th>
</tr>
<?php
if (isset($_GET['name']))
{
$letter = $_GET['name'];
$A = mysql_connect("LocalHost","root","") or die("Error in MYSQL Connection!");
mysql_select_db("payroldb",$A) or die("Error in DataBase!");
$B = mysql_query("Select * from tblemp where FirstName like '%".$letter."%' || LastName like '%".$letter."%' || FatherName like '%".$letter."%' || Address like '%".$letter."%'",$A) or die("Error in Insert Query.");
$num_rows = mysql_num_rows($B);
if($num_rows == 1){
echo "<h2> $num_rows Employee </h2>";
}
else
echo "<h2> $num_rows Employees </h2>";
for($a=0; $a<$num_rows; $a++)
{
$rec = mysql_fetch_array($B);
echo "<tr>";
echo "<td>$rec[0]</td>";//EID
echo "<td>$rec[1]</td>";//First Name
echo "<td>$rec[2]</td>";//Last Name
echo "<td><img src='images/$rec[3]' width=50 height=50 border=5 Title='$rec[1]'></td>";//Image
echo "<td>$rec[4]</td>";//Father Name
echo "<td>$rec[5]</td>";//NIC
echo "<td>$rec[6]</td>";//Ph.No
echo "<td>$rec[7]</td>";//Address
echo "<td>$rec[8]</td>";//DOB
echo "<td>$rec[9]</td>";//Gender
echo "<td>$rec[10]</td>";//Joining Date
echo "<td>$rec[11]</td>";//Religion
echo "<td>$rec[12]</td>";//Designation
echo "<td>$rec[13]</td>";//Department
echo "<td>$rec[14]</td>";//Working Status
echo "<td>$rec[15]</td>";//Reg No
echo "<td><a href='SalarySlip.php?A=$rec[0]'>Salary Slip</a></td>";
echo "</tr>";
}
mysql_close($A);
}
?>
</table>
</div><!-- /.col-sm-6 -->
Update Employee:
<div class="row">
<div class="col-sm-6">
<!-- Begin basic form elements -->
<div class="the-box">
<h4 class="small-title">Employee's Information</h4>
<form action="Update-emp.php" method="POST" Enctype="multipart/form-data">
<div class="form-group">
<label>ID</label>
<input type="text" name="txtID" class="form-control rounded" Value="<?php echo $_GET['A'] ?>" readonly>
</div>
<div class="form-group">
<label>First Name</label>
<input type="text" name="txtName" class="form-control rounded" Value="<?php echo $_GET['B'] ?>" required>
</div>
<div class="form-group">
<label>Last Name</label>
<input type="text" name="txtLName" class="form-control rounded" Value="<?php echo $_GET['C'] ?>" required>
</div>
<div class="form-group">
<label>Image</label>
<input type="text" name="txtUImg" class="form-control rounded" Value="<?php echo $_GET['D'] ?>" required>
</div>
<div class="form-group">
<label>Father Name</label>
<input type="text" name="txtFName" class="form-control rounded" Value="<?php echo $_GET['E'] ?>" required>
</div>
<div class="form-group">
<label>NIC No</label>
<input type="text" name="txtNIC" class="form-control rounded" Value="<?php echo $_GET['F'] ?>" required>
</div>
<div class="form-group">
<label>Phone No</label>
<input type="text" name="telno" class="form-control rounded" Value="<?php echo $_GET['G'] ?>" required>
</div>
<div class="form-group">
<label>Address</label>
<input type="text" name="txtadres" class="form-control rounded" Value="<?php echo $_GET['H'] ?>" required>
</div>
<div class="form-group">
<label>Date of Birth</label>
<input type="text" name="DOB" class="form-control rounded" Value="<?php echo $_GET['I'] ?>" data-date-format="mm-dd-yy" required>
</div>
<div class="form-group">
<label>Gender</label>
<input type="text" name="rdoGend" class="form-control rounded" value="<?php echo $_GET['J']?>" required>
</div>
<div class="form-group">
<label>Joining Date</label>
<input type="text" name="JDate" class="form-control rounded" Value="<?php echo $_GET['K'] ?>" data-date-format="mm-dd-yy" required>
</div>
<div class="form-group">
<label>Religion</label>
<input type="text" name="lstRlgn" class="form-control rounded" Value="<?php echo $_GET['L'] ?>">
</div>
<div class="form-group">
<label>Designation</label>
<input type="text" name="txtDesg" class="form-control rounded" Value="<?php echo $_GET['M'] ?>" required>
</div>
<div class="form-group">
<label>Department</label>
<input type="text" name="lstDept" class="form-control rounded" Value="<?php echo $_GET['N'] ?>">
</div>
<div class="form-group">
<label>Working Status</label>
<input type="text" name="txtStatus" class="form-control rounded" Value="<?php echo $_GET['O'] ?>" required>
</div>
<div class="form-group">
<label>Registration No</label>
<input type="text" name="txtRegno" class="form-control rounded" Value="<?php echo $_GET['P'] ?>" required>
</div>
<div class="form-group">
<input class="btn btn-primary" type="submit" name="btnUpdate" value="Update">
<input class="btn btn-primary" type="button" onClick="Back()" value="Back">
</div>
</form>
<script>
function Back()
{
document.location.href='view-emp.php';
}
</script>
</div><!-- /.the-box -->
<!-- End basic form elements -->
</div><!-- /.col-sm-6 -->
<?php
if(isset($_POST['btnUpdate']))
{
$ID = $_POST['txtID'];
$NM = $_POST['txtName'];
$LN = $_POST['txtLName'];
$IM = $_POST['txtUImg'];
$FN = $_POST['txtFName'];
$CC = $_POST['txtNIC'];
$PN = $_POST['telno'];
$AD = $_POST['txtadres'];
$DB = $_POST['DOB'];
$GN = $_POST['rdoGend'];
$JD = $_POST['JDate'];
$RL = $_POST['lstRlgn'];
$DG = $_POST['txtDesg'];
$DP = $_POST['lstDept'];
$ST = $_POST['txtStatus'];
$RN = $_POST['txtRegno'];
$A = mysql_connect("LocalHost","root","") or die("Error in MYSQL Connection");
mysql_select_db("payroldb",$A) or die("Error in Data Base");
mysql_query("Update tblemp set FirstName='$NM', LastName='$LN',Image='$IM', FatherName='$FN', NIC='$CC', PhoneNo='$PN', Address='$AD', DOB='$DB', Gender='$GN', JoiningDate='$JD', Religion='$RL', Designation='$DG', Department= '$DP', WorkingStatus='$ST', RegNo='$RN' Where ID='$ID'", $A) or die("Error in Update Query");
mysql_close($A);
echo '<script language="javascript">';
echo 'alert("Updated Successfuly...!")';
echo '</script>';
}
?>
View Employee:
<?php
if(isset($_GET['A']))
{
$P = $_GET['A'];
$A = mysql_connect("localhost","root","") or die ("error in sql connection");
mysql_select_db("payroldb",$A) or die ("error in database");
mysql_query("delete from tblemp Where ID=$P",$A) or die ("error in query");
mysql_close($A);
}
?>
<?php
$A = mysql_connect("LocalHost","root","") or die("Error in MYSQL Connection!");
mysql_select_db("payroldb",$A) or die("Error in DataBase!");
$B = mysql_query("Select * from tblemp",$A) or die("Error in Select Query.");
$num_rows = mysql_num_rows($B);
if($num_rows == 1)
{
echo "<h2> $num_rows Employee </h2>";
}
else
{
echo "<h2> $num_rows Employees </h2>";
}
?>
<p style="color:#F00">Click on the First Name to edit the employee's Information...!</p>
&
<p style="color:#F00">Click on the Last Name to delete the employee's Information...!</p>
<table border="1">
<thead bgcolor="#FFFFFF">
<tr>
<th>Emp ID</th>
<th>First Name</th>
<th>Last Name</th>
<th>Image</th>
<th>Father Name</th>
<th>NIC</th>
<th>Phone Number</th>
<th>Address</th>
<th>Date Of Birth</th>
<th>Gender</th>
<th>Joining Date</th>
<th>Religion</th>
<th>Designation</th>
<th>Department</th>
<th>Working Status</th>
<th>Reg.No</th>
</tr>
</thead>
<?php
for($a=0; $a<$num_rows; $a++)
{
$rec=mysql_fetch_array($B);
echo "<tr>";
echo "<td>$rec[0]</td>";//EID
echo "<td><a href='Update-emp.php?A=$rec[0] &B=$rec[1] &C=$rec[2] &D=$rec[3] &E=$rec[4] &F=$rec[5] &G=$rec[6] &H=$rec[7] &I=$rec[8] &J=$rec[9] &K=$rec[10] &L=$rec[11] &M=$rec[12] &N=$rec[13] &O=$rec[14] &P=$rec[15]'>$rec[1]</a></td>";//First Name?>
<td><a onClick="return confirm('Are you sure you want to delete this record?')"
href='view-emp.php?A=<?php echo $rec[0] ?>'><?php echo " $rec[2]" ?></a></td><?php //Last Name
echo "<td><img src='images/$rec[3]' width=50 height=50 border=5 Title='$rec[1]'></td>";//Image
echo "<td>$rec[4]</td>";//Father Name
echo "<td>$rec[5]</td>";//NIC
echo "<td>$rec[6]</td>";//Ph.No
echo "<td>$rec[7]</td>";//Address
echo "<td>$rec[8]</td>";//DOB
echo "<td>$rec[9]</td>";//Gender
echo "<td>$rec[10]</td>";//Joining Date
echo "<td>$rec[11]</td>";//Religion
echo "<td>$rec[12]</td>";//Designation
echo "<td>$rec[13]</td>";//Department
echo "<td>$rec[14]</td>";//Working Status
echo "<td>$rec[15]</td>";//Reg No
echo "</tr>";
}
mysql_close($A);
?>
</table>
No comments:
Post a Comment