Location: PHPKode > projects > E-hris > nextofkin.php
   * e-hris (Electonic-Human Resource Information System v 1.3.0 Alpha) Is an open source human resource information management system
   * developed to automate all aspects of human resource management, with the dual benefits of reducing the workload of the HR department as well as increasing the efficiency of the department by standardising
   * HR processes for any organization from small-enterprises to large scale organizations.
   * Copyright (C) 2008  David Muturi

   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.

   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * GNU General Public License for more details.

   * You should have received a copy of the GNU General Public License
   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
<!DOCTYPE html
	PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<title>E-HRIS Emergency Contacts</title>
	<link rel="stylesheet" type="text/css" href="css/employees.css" />
	<link rel="stylesheet" type="text/css" href="css/main.css"/>
	<link rel="stylesheet" href="../corehrmis/js/example.css" TYPE="text/css" MEDIA="screen">
	<link href="css/text.css" rel="stylesheet" type="text/css" />
<style type="text/css">
.style2 {font-size: x-small}
.style3 {	color: #FFFFFF;
	font-weight: bold;
.style4 {color: #FFFFFF}
.info   { color: black; background-color: transparent; font-weight: normal; }
  .warn   { color: rgb(120,0,0); background-color: transparent; font-weight: normal; }
  .error  { color: red; background-color: transparent; font-weight: bold }
 <style type="text/css">
.style7 {
	color: #FF0000;
	font-size: 9px;
	font-family: "Courier New", Courier, mono;
.style8 {
	background-color: transparent;
	color: red;
	font-size: 12px;
 <link rel="stylesheet" type="text/css" href="css/epoch_styles.css"/>
<style type="text/css">
.style3 {color: #FFFFFF;
	font-weight: bold;
.style4 {color: #000000}
 <link rel="stylesheet" type="text/css" href="css/epoch_styles.css"/>
 <link rel="stylesheet" type="text/css" href="css/jqueryslidemenu.css" />
 <link rel="stylesheet" type="text/css" href="ajaxtabs/ajaxtabs.css" />

<!--[if lte IE 7]>
<style type="text/css">
html .jqueryslidemenu{height: 1%;} /*Holly Hack for IE7 and below*/

<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/jqueryslidemenu.js"></script>
<script type="text/javascript" src="ajaxtabs/ajaxtabs.js">

* Ajax Tabs Content script v2.2- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code

 <script type="text/javascript" src="css/epoch_classes.js"></script>
 <script type="text/javascript" src="js/formval.js"></script> 
 <script language="JavaScript" src="js/calendar1.js"></script><!--  -->
 <script type="text/Javascript">
 function validateOnSubmit() {
	var elem;
    var errs=0;
	// execute all element validations in reverse order, so focus gets
    // set to the first one in error.
	if (!validatePresent(document.forms.nokfrm.relationship,'inf_relationship'))  errs += 1;
	if (!validatePresent(document.forms.nokfrm.address,'inf_address'))  errs += 1; 
	if (!validatePresent(document.forms.nokfrm.lname,'inf_lname'))  errs += 1; 
	if (!validatePresent(document.forms.nokfrm.fname,'inf_fname'))  errs += 1; 
	if (errs>1)  alert('There are fields which need correction before submitting');
    if (errs==1) alert('There is a field which needs correction before submitting');
  return (errs==0);
<body bgcolor="#FFFFFF">
  if (empty($_SESSION["username"]))
    die("<meta http-equiv='refresh' content='1;url=login.php'>");
   $username = $_SESSION["username"];
  include "includes/functions.php";
  include "includes/config.php";
  require_once "includes/db.php";
  $d = new dbC();
  $d->connect($db_host, $db_user, $db_pass, $db); 
  if (!empty($_GET["empid"]))
  if (!empty($_POST["empid"]))
  if (!empty($_GET["action"]))

  //employee details for display only
  if (!empty($empid))
    $sqlstr="select * from prmember left join tbl_titles on tbl_titles.id=emptitle where prmember.rowid=$empid";
	$row = $d->fetch_object($query);
	$dispname="&nbsp;&nbsp;<font face = Verdana size=2><b>Add Emergency Contact Details For: <a href=employees.php?empid=$empid&action=edit>" . $row->title. $row->FullName."</a>";
	$dispname = $dispname."&nbsp;&nbsp;&nbsp;Payroll Number : ".$row->MemberNo."</b></font>";
  if (!empty($_GET["nokid"]))
    $sqlstr="select * from tbl_nextofkin where id=$id";
	$relationship = $row->relationship;
    $fname = $row->fname;
    $mname = $row->mname;
    $lname = $row->lname;
    $address = $row->address;
	$mphone = $row->mphone;
	$email= $row->email;
    $empid = $row->empid_fk;
    $id=  $row->id;
  if (!empty($_POST["fname"]))
    $relationship = empty($_POST["relationship"]) ? 'NULL' : "'" . $_POST["relationship"] . "'";
    $fname = "'".$_POST["fname"]."'";
    $mname = empty($_POST["mname"]) ? 'NULL' : "'" . $_POST["mname"] . "'";
	$mphone = empty($_POST["mphone"]) ? 'NULL' : "'" . $_POST["mphone"] . "'";
	$email = empty($_POST["email"]) ? 'NULL' : "'" . $_POST["email"] . "'";
    $lname = "'".$_POST["lname"]."'";
    $address = "'".$_POST["address"]."'";
    $empnum = "'".$_POST["empid"]."'";;
    $action =$_POST["action"];
	$id= "'".$_POST["id"]."'";
	//echo $action;

   if (!empty($action) && ($action=="edit"))
     $query="update tbl_nextofkin set fname=$fname,lname=$lname,mname=$mname,address=$address,empid_fk=$empnum,relationship=$relationship,mphone=$mphone,email=$email where id=$id";
     $query="insert into tbl_nextofkin (fname,lname,mname,address,empid_fk,relationship,mphone,email) values ($fname,$lname,$mname,$address,$empnum,$relationship,$mphone,$email)";
   //process delete
  if ($action=="delete_go")
   $sqlstr="delete from tbl_nextofkin where id=$id";
   echo "<meta http-equiv='refresh' content='1;url=nextofkin.php?empid=$empid'>";
   if (!empty($query))
    $result = $d->query($query);

	if (!$result) 
     	die('Invalid query - Record Not Saved: ' . mysql_error());
	   echo "<font face = Tahoma size=1><b>Record Successfully Saved </b></font>";
	   echo "<meta http-equiv='refresh' content='1;url=nextofkin.php?empid=$empid'>";
  } createmenu($empid,$username,$d); 
<span>&nbsp;<br><br><? if (!empty($dispname)) echo $dispname; ?></span>
 <table  id="main" cellspacing="0" cellpadding="0" align="center" width="50%" >
     <td   bgcolor="#FFFFFF" ><form name="nokfrm" method="post" action="nextofkin.php">
         <table width="100%"  border="0"  bgcolor="#F7F7F7">
             <td width="17%"><div align="right">Name(s)</div></td>
             <td width="22%"><input name="fname" type="text" id="fname" <?   if (!empty($fname)) echo "value=$fname";?>>
                 <div class="highlight" id="inf_fname">&nbsp;</div></td>
             <td width="20%"><div align="right">Middle Name </div></td>
             <td width="10%"><div align="right">
                 <input name="mname" type="text" id="mname" <? if (!empty($mname)) echo "value=$mname";?>>
                 <div class="highlight" id="inf_mname">&nbsp;</div></td>
             <td width="10%"><div align="right">Last Name </div></td>
             <td width="21%"><input name="lname" type="text" id="lname" <? if(!empty($lname)) echo "value=$lname";?>>
                 <div class="highlight" id="inf_lname">&nbsp;</div></td>
             <td><div align="right">Address</div></td>
             <td><input name="address" type="text" id="address" size="30" <? if(!empty($address))echo "value=$address";?>>
                 <div class="highlight" id="inf_address">&nbsp;</div></td>
             <td><div align="right">Mobile Phone </div></td>
             <td><div align="right">
                 <input name="mphone" type="text" id="mphone" <? if(!empty($mphone))echo "value=$mphone";?>>
             <td><div align="right">Relationship</div></td>
             <td><input name="relationship" type="text" id="relationship" <? if(!empty($relationship)) echo "value=$relationship";?>></td>
             <td><div align="right">Email</div></td>
             <td><input name="email" type="text" id="email" <? if(!empty($email))echo "value=$email";?>></td>
             <td><div align="right"></div></td>
             <td colspan="2">&nbsp;</td>
             <td><input type="submit" name="Submit" value="Submit" onClick="return validateOnSubmit()">
                 <input type="hidden" name="empid" <?  if(!empty($empid)) echo "value=$empid"; ?>>
                 <input type="hidden" name="action" <? if (!empty($action)) echo "value=$action"; ?>>
                 <input type="hidden" name="id" <? if (!empty($id)) echo "value=$id"; ?>></td>
    <td  bgcolor="#FFFFFF" ><table width="100%"  border="0">
        <th width="5%"><span class="style4">No.</span></th>
        <th width="5%"><span class="style4">Name</span></th>
        <th width="10%"><span class="style4">Address</span></th>       
        <th width="10%"><span class="style4">Relation Ship</span></th>       
        <th width="5%"><span class="style4">Mobile</span></th>        
        <th width="5%"><span class="style4">Email</span></th>
        <th width="5%"><span class="style4">Action</span></th>           
		if (!empty($empid))
	      $sqlstr="select * from tbl_nextofkin where empid_fk=$empid";
		  $result=$d->query($sqlstr) or die(mysql_error());;
		  while ($row=$d->fetch_object($result))
		    echo "<tr>";
		    echo "<td>".$row->id."</td>";
		    echo "<td>".$row->fname." ".$row->mname." ".$row->lname."</td>";
		    echo "<td>".$row->address."</td>";
		    echo "<td>".$row->relationship."</td>";
			echo "<td>".$row->mphone."</td>";
			echo "<td>".$row->email."</td>";
		    echo "<td> <a href=nextofkin.php?nokid=$row->id&action=edit>Edit</a> | <a href=nextofkin.php?action=delete_go&nokid=$row->id onClick=\"Javascript:return confirm('Are you sure you want to delete this record?','Confirm Delete')\"> Delete</a></td>";
		    echo "</tr></td>";
    <td  bgcolor="#FFFFFF" >&nbsp;</td>


Return current item: E-hris