
PK 
<?php
ob_start();
//error_reporting(E_ALL ^ E_NOTICE);
@session_start();
ini_set('allow_url_include',1);
date_default_timezone_set("Asia/Kolkata");
set_time_limit(600);
ini_set('max_execution_time',600);
include '../includes/settings/constant.php';
//include '../includes/settings/db.php';
require_once '../includes/settings/PDODB.php';
include '../includes/modules/functions.php';
$function = new FUNCTIONS();
if (!empty($_SESSION['adminId']) && !empty($_SESSION['admin_role_id'])) {
if($_SESSION['admin_role_id']==1){
//header("Location: index.php");
}elseif($_SESSION['admin_role_id']==2){
header("Location: ../dashboard/index.php");
}
}else{
header("Location: ../index.php");
exit();
}
$ipaddress = $function->getRealIpAddr();
$member_id = $_GET['id'];
$members = $function->getMemberDetails($member_id,1);
//print_r($member_id);
//print_r($_POST);
if(isset($_POST['btnAddfMember'])){
$members =$_POST;
if(!empty($members['name'])){
for ($i=0; $i < sizeof($members['name']); $i++) {
$name= $members['name'][$i];
$age= $members['age'][$i];
$relation= $members['relation'][$i];
$blood_gp= $members['blood_gp'][$i];
$pdodb = PDODB::getInstance();
$sql = "INSERT INTO family_member SET member_id='$member_id',name='$name',age='$age',relation='$relation',blood_gp='$blood_gp',ipaddress=''";
$result = $pdodb->query($sql);
//echo $result; exit;
PDODB::closeInstance();
if (!empty($result)) {
echo "<script>window.location.href='../member/create-member.php';</script>";
}
}
}
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>INSPINIA | Basic Form</title>
<?php include_once '../layout/style.php'; ?>
</head>
<body>
<div id="wrapper">
<?php include_once '../layout/side-bar.php'; ?>
<div id="page-wrapper" class="gray-bg">
<?php include_once '../layout/header.php'; ?>
<div class="row wrapper border-bottom white-bg page-heading">
<div class="col-lg-10">
<h2>Add Family Member Form</h2>
<ol class="breadcrumb">
<li>
<a href="index.html">Home</a>
</li>
<li>
<a>Forms</a>
</li>
<li class="active">
<strong>Add Family Member Form</strong>
</li>
</ol>
</div>
<div class="col-lg-2">
</div>
</div>
<div class="row">
<div class="col-lg-12">
<div class="ibox float-e-margins">
<div class="wrapper wrapper-content animated fadeInRight">
<div class="row">
<div class="col-lg-12">
<div class="ibox float-e-margins">
<div class="ibox-title">
</div>
<div class="ibox-content">
<div class="table-responsive">
<form method="POST" action="">
<table class="table table-striped table-bordered table-hover dataTables-example" id="myTable">
<thead>
<tr>
<th>Name</th>
<th>Age</th>
<th>Relation</th>
<th>Blood </th>
<td>Action</td>
</tr>
</thead>
<tbody>
<?php
for($i=0;$i<count($members);$i++){
?>
<tr>
<input type="hidden" name="member_id" value="<?php echo $member_id; ?>">
<td><input type="text" value="<?=$members[$i]['name'];?>" id="name" name="name[]"></td>
<td><input type="text" value="<?=$members[$i]['age'];?>" id="age" name="age[]"></td>
<td><input value="<?=$members[$i]['relation'];?>" type="text" id="relation" name="relation[]"></td>
<td><input value="<?=$members[$i]['blood_gp'];?>" type="text" id="blood_gp" name="blood_gp[]"></td>
<td><input type="button" class="button" value="Add more" onclick="addField();"></td>
</tr>
<?php } ?>
</tbody>
</table>
<div class="form-group">
<div class="col-sm-4 col-sm-offset-2">
<button class="btn btn-white" type="submit">Cancel</button>
<button class="btn btn-primary" name="btnAddfMember" id="btnAddfMember" type="submit">Add Family Member</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<?php include_once '../layout/script.php'; ?>
<script>
function tossterMsgAlert(msg='Welcome',title='') {
toastr.options = {
closeButton: true,
//debug: false,
newestOnTop: false,
//progressBar: false,
positionClass: 'toast-top-center',
preventDuplicates: true,
//onclick: null,
//showDuration: 300,
//hideDuration: 1000,
timeOut: 2000,
//extendedTimeOut: 1000,
//showEasing: 'swing',
//hideEasing: 'linear',
//showMethod: 'fadeIn',
hideMethod: 'fadeOut'
};
toastr.warning(title,msg);
}
</script>
<script>
function addField (argument) {
var myTable = document.getElementById("myTable");
var currentIndex = myTable.rows.length;
var currentRow = myTable.insertRow(-1);
var nameBox = document.createElement("input");
nameBox.setAttribute("name", "name[]" + currentIndex);
var ageBox = document.createElement("input");
ageBox.setAttribute("name", "age[]" + currentIndex);
var relationBox = document.createElement("input");
relationBox.setAttribute("name", "relation[]" + currentIndex);
var blood_gpBox = document.createElement("input");
blood_gpBox.setAttribute("name", "blood_gp[]" + currentIndex);
var addRowBox = document.createElement("input");
addRowBox.setAttribute("type", "button");
addRowBox.setAttribute("value", "Add more");
addRowBox.setAttribute("onclick", "addField();");
addRowBox.setAttribute("class", "button");
var currentCell = currentRow.insertCell(-1);
currentCell.appendChild(nameBox);
currentCell = currentRow.insertCell(-1);
currentCell.appendChild(ageBox);
currentCell = currentRow.insertCell(-1);
currentCell.appendChild(relationBox);
currentCell = currentRow.insertCell(-1);
currentCell.appendChild(blood_gpBox);
currentCell = currentRow.insertCell(-1);
currentCell.appendChild(addRowBox);
}
</script>
</body>
</html>


PK 99