
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);
require_once '../includes/settings/PDODB.php';
include '../includes/modules/functions.php';
$function = new FUNCTIONS();
if(empty($_SESSION['adminId'])){
header("Location: ../index.php");
exit();
}
if(isset($_POST['btnAddfPollQ'])){
//print_r($_POST); exit;
$members =$_POST;
$title= !empty($_POST['title'])?trim($_POST['title']):"";
$title = htmlentities($title, ENT_QUOTES);
$pdodb = PDODB::getInstance();
$sql = "INSERT INTO `tb_pollquestion` SET title='$title'";
$result = $pdodb->query($sql);
$lastInsertIdpoll = $pdodb->lastInsertId();
if(!empty($members['name'])){
for ($i=0; $i < sizeof($members['name']); $i++) {
$name= $members['name'][$i];
$name = htmlentities($name, ENT_QUOTES);
$pdodb = PDODB::getInstance();
$sql2 = "INSERT INTO `tb_polloptions` SET q_id='$lastInsertIdpoll',description='$name'";
$result2 = $pdodb->query($sql2);
//echo $result; exit;
PDODB::closeInstance();
if ($result2 ==true) {
$error_msg = "Successfully Added.";
}
}
}
}
?>
<!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'; ?>
<link href="../css/plugins/switchery/switchery.css" rel="stylesheet">
</head>
<body>
<div id="wrapper">
<?php $currentPage = 'poll-create'; 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-8">
<h2>Create New Poll or Voting Question</h2>
</div>
</div>
<div class="row">
<div class="col-lg-8">
<div class="ibox float-e-margins">
<div class="ibox-title back-change">
</div>
<div class="ibox-title back-change">
<?php if (!empty($error_msg)) { ?>
<div class="alert alert-success" id="alert-success">
<a href="#" class="close" data-dismiss="alert" aria-label="close" title="close">×</a>
<strong><?=$error_msg;?></strong>
</div>
<?php } ?>
</div>
<div class="ibox-content">
<div class="row">
<form method="POST" action="" enctype="multipart/form-data" id="addPollQ">
<div class="col-sm-12">
<div class="form-group">
<label>Question Title*</label>
<input type="text" placeholder="Enter Question Title" name="title" id="title" class="form-control">
</div>
</div>
<div class="col-sm-12">
<table class="table table-striped table-bordered table-hover" id="myTable">
<thead>
<tr>
<th>Name</th>
<td>ADD</td>
<td>Delete</td>
</tr>
</thead>
<tbody>
<tr>
<td><input style="width: 100%;" type="text" id="name" name="name[]" required=""></td>
<td>
<input type="button" class="btn btn-success" value="Add Row" onclick="addField();">
</td>
<td>
<input type="button" class="btn btn-danger" id="delPOIbutton" value="Delete Row" onclick="deleteRow(this)" />
</td>
</tr>
</tbody>
</table>
</div>
<div class="col-sm-12">
<div class="form-group">
<div>
<button class="btn btn-lg btn-danger pull-right m-t-n-xs" name="btnAddfPollQ" id="btnAddfPollQ" type="submit"><strong>SUBMIT</strong></button>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
<?php include_once '../layout/script.php'; ?>
<!-- Switchery -->
<script src="../js/plugins/switchery/switchery.js"></script>
<!-- Page-Level Scripts -->
<script>
$(document).ready(function(){
$('.dataTables-example').DataTable({
dom: '<"html5buttons"B>lTfgitp',
buttons: [
{ extend: 'copy'},
{extend: 'csv'},
/*{extend: 'excel', title: 'ExampleFile'},
{extend: 'pdf', title: 'ExampleFile'},*/
/*{extend: 'print',
customize: function (win){
$(win.document.body).addClass('white-bg');
$(win.document.body).css('font-size', '10px');
$(win.document.body).find('table')
.addClass('compact')
.css('font-size', 'inherit');
}
}*/
]
});
});
</script>
<script type="text/javascript">
$("#addPollQ").validate({
rules: {
title: {
required: true
}
},
messages: {
title: {
required: "Please Enter Question Title"
}
},
submitHandler: function(form) {
form.submit();
}
});
</script>
<script>
//add insert
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);
nameBox.setAttribute("required", "false[]" + currentIndex);
var addRowBox = document.createElement("input");
addRowBox.setAttribute("type", "button");
addRowBox.setAttribute("value", "Add Row");
addRowBox.setAttribute("onclick", "addField();");
addRowBox.setAttribute("class", "btn btn-success");
var deleteRowBox = document.createElement("input");
deleteRowBox.setAttribute("type", "button");
deleteRowBox.setAttribute("value", "Delete Row");
deleteRowBox.setAttribute("onclick", "deleteRow(this);");
deleteRowBox.setAttribute("class", "btn btn-danger");
var currentCell = currentRow.insertCell(-1);
currentCell.appendChild(nameBox);
currentCell = currentRow.insertCell(-1);
currentCell.appendChild(addRowBox);
currentCell = currentRow.insertCell(-1);
currentCell.appendChild(deleteRowBox);
}
//delete row
function deleteRow(row){
var i=row.parentNode.parentNode.rowIndex;
document.getElementById('myTable').deleteRow(i);
}
</script>
</body>
</html>


PK 99