File: /var/www/nclive/technc/edit.php
<?php
include 'header.php';
include '../wp-config.php';
// ini_set('display_errors', 1);
// ini_set('display_startup_errors', 1);
// error_reporting(E_ALL);
$TABLE_POST = 'naukri_wp_posts';
$TABLE_POSTMETA = 'naukri_wp_postmeta';
$TABLE_YOAST_INDEXABLE = 'naukri_wp_yoast_indexable';
$TABLE_EXAM = 'sp_exam';
$TABLE_EXAM_CATEGORY = 'sp_exam_category';
$TABLE_EXAM_TYPE = 'sp_exam_type';
$TABLE_AGE_LIMIT = 'sp_age_limit';
$TABLE_QUALIFICATION = 'sp_qualification';
$TABLE_STATES = 'sp_states';
$TABLE_STATE_COMMISSION = 'sp_state_commission';
$TABLE_EXAM_UPDATE = 'sp_exam_update';
$user_id = 1;
$message = ''; // for displayin error and success msgs
$curDate = date('Y-m-d H:i:s');
$userid = $_REQUEST['id'];
$query = "select e.exam_id,e.exam_name,e.exam_year,e.post_name,e.h1_title,e.url_slug,e.fee_desc,e.qualification_desc,e.age_desc,e.sp_exam_id,e.exam_summary,e.important_notes,e.physical,e.total_vacancy,e.off_web_link,e.display_order,e.top_display_order,e.status,e.cat_id,e.type_id,et.type,e.age_id,e.age_to,e.age_from,a.age,e.qualification_id,q.quali_name,e.state_id,s.state_name,e.status,e.state_commission,sc.comm_name,e.total_time,e.total_marks,e.exam_mode,e.negative_marking, e.other_info,e.other_info_tabname,ec.name,e.fee from $TABLE_EXAM as e
left join $TABLE_EXAM_CATEGORY as ec on ec.cat_id=e.cat_id
left join $TABLE_EXAM_TYPE as et on et.type_id=e.type_id
left join $TABLE_AGE_LIMIT as a on a.age_lim_id=e.age_id
left join $TABLE_QUALIFICATION as q on q.qualification_id=e.qualification_id
left join $TABLE_STATES as s on s.state_id=e.state_id
left join $TABLE_STATE_COMMISSION as sc on sc.id=e.state_commission
where e.exam_id='$userid'";
$sql = $db->prepare($query);
$sql->execute();
$row = $sql->fetch();
if ($row['status'] == '1') {
$status = "Active";
} else if ($row['status'] == '0') {
$status = "Deactive";
}
/*----------get details for post name and slug--------*/
$slug = $row['url_slug'];
$checkPost = $db->prepare("SELECT ID FROM $TABLE_POST WHERE post_name='$slug'");
$checkPost->execute();
$rowPost = $checkPost->fetch();
$postID = $rowPost['ID'];
/*----------get details for meta values--------*/
$keywordQry = $db->prepare("SELECT meta_value FROM $TABLE_POSTMETA where post_id='$postID' AND meta_key='_yoast_wpseo_metakeywords'");
$keywordQry->execute();
$getMetaKeyword = $keywordQry->fetch();
$metadescQry = $db->prepare("SELECT meta_value from $TABLE_POSTMETA where post_id='$postID' AND meta_key='_yoast_wpseo_metadesc'");
$metadescQry->execute();
$getMetaDesc = $metadescQry->fetch();
$metakeyQry = $db->prepare("SELECT meta_value from $TABLE_POSTMETA where post_id='$postID' AND meta_key='_yoast_wpseo_focuskw'");
$metakeyQry->execute();
$getMetaKey = $metakeyQry->fetch();
$metatitleQry = $db->prepare("SELECT meta_value from $TABLE_POSTMETA where post_id='$postID' AND meta_key='_yoast_wpseo_title'");
$metatitleQry->execute();
$getMetaTitle = $metatitleQry->fetch();
// submit form
if (isset($_REQUEST['submit'])) {
$exam = $_REQUEST['exam_type'];
$examname = $_REQUEST['exam_name'];
$postname = $_REQUEST['post_name'];
$exam_url = $_REQUEST['url'];
$examtype = $exam;
$exam_year = $_REQUEST['exam_year'];
$quali = $_REQUEST['quali'];
$quali_desc = $_REQUEST['quali_dis'];
$headTitle = $_REQUEST['headTitle'];
$meta_title = $_REQUEST['metaTitle'];
$meta_key = $_REQUEST['metafkeyword'];
$meta_keyword = $_REQUEST['metaKeyword'];
$meta_desc = $_REQUEST['metaDesc'];
// $age = $_REQUEST['age'];
$age_to = $_REQUEST['age_to'];
$age_from = $_REQUEST['age_from'];
$age_desc = $_REQUEST['age_desc'];
$exam_summary = $_REQUEST['summary'];
$imp_notes = $_REQUEST['imp_notes'];
$exam_id = $_REQUEST['examid'];
$fee = $_REQUEST['fee'];
$feess = $_REQUEST['fee_desc'];
$physical = $_REQUEST['physical'];
$vacancy = $_REQUEST['vacancy'];
$link = $_REQUEST['link'];
$order = $_REQUEST['order'];
$top_order = $_REQUEST['top_order'];
$status = $_REQUEST['status'];
$time = $_REQUEST['total_time'];
$mark = $_REQUEST['marks'];
$mode = $_REQUEST['mode'];
$marking = $_REQUEST['marking'];
$other_info = $_REQUEST['other_info'];
$tab = $_REQUEST['tabname'];
$exam_category = $_REQUEST['category'];
$state = $_REQUEST['state'];
$state_commission = $_REQUEST['state_commission'];
$query = "UPDATE $TABLE_EXAM SET `exam_name`='$examname', `post_name`='$postname',`h1_title`='$headTitle',`exam_year`='$exam_year', `exam_summary`='$exam_summary', `url_slug`='$exam_url', `type_id`='$examtype', `cat_id`='$exam_category', `state_id`='$state', `state_commission`='$state_commission', `qualification_id`='$quali', `qualification_desc`='$quali_desc', `age_id`='',`age_to`='$age_to', `age_from`='$age_from', `age_desc`='$age_desc', `fee_desc`='$fee',`physical`='$physical' ,`total_vacancy`='$vacancy', `total_time`='$time', `total_marks`='$mark', `exam_mode`='$mode', `negative_marking`='$marking', `other_info`='$other_info', `other_info_tabname`='$tab',`important_notes`='$imp_notes',`off_web_link`='$link', `display_order`='$order', `status`='$status',`top_display_order`='$top_order',`sp_exam_id`='$exam_id',`update_date`='$curDate',fee='$feess' where `exam_id`='$userid'";
$sql = $db->prepare($query);
$sql->execute();
update_post_meta($postID, '_yoast_wpseo_title', $meta_title);
update_post_meta($postID, '_yoast_wpseo_focuskw', $meta_key);
update_post_meta($postID, '_yoast_wpseo_metadesc', $meta_desc);
update_post_meta($postID, '_yoast_wpseo_metakeywords', $meta_keyword);
$query2 = "INSERT INTO $TABLE_EXAM_UPDATE SET `type`='U',`exam_id`='$userid',`user_id`='$user_id',`date`='$curDate',`description`='$meta_desc'";
$sql2 = $db->prepare($query2);
$successResult = $sql2->execute();
if ($successResult) {
$message = '<div class="alert alert-success"><strong>Data Updated successfully</strong></div>';
} else {
$message = '<div class="alert alert-danger"><strong>Error In Page Updation </strong></div>';
}
}
?>
<main id="main-container">
<div class="content content-narrow">
<div class="row">
<div class="col-lg-12">
<h2 class="content-heading">Update Details</h2>
<div class="block">
<div class="block-header">
<ul class="block-options">
<li>
<button type="button"><i class="si si-settings"></i></button>
</li>
</ul>
<h3 class="block-title"></h3>
</div>
<div class="block-content block-content-narrow">
<?php echo $message; ?>
<form class="js-validation-bootstrap form-horizontal" action="edit.php?id=<?php echo $userid; ?>" method="post">
<div class="form-group">
<label class="col-md-2 control-label" for="val-username">Exam Name<span class="text-danger">*</span></label>
<div class="col-md-10">
<input class="form-control" type="text" name="exam_name" placeholder="example:CGL Tier-I, SBI-Clerk" value="<?php echo $row['exam_name']; ?>">
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label" for="val-email">Post Name<span class="text-danger">*</span></label>
<div class="col-md-8">
<input class="form-control" type="text" name="post_name" placeholder="Enter post name" value="<?php echo $row['post_name']; ?>" onkeyup="convertToSlug(this.value)" onload="convertToSlug(this.value)">
</div>
<div class="col-md-2">
<select class="js-select2 form-control" name="exam_year">
<option value="2017">2017</option>
<option selected="selected" value="<?php echo $row['exam_year']; ?>"><?php echo $row['exam_year']; ?></option>
<option value="2019">2019</option>
<option value="2020">2020</option>
<option value="2021">2021</option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label" for="val-password">Url slug<span class="text-danger">*</span></label>
<div class="col-md-10">
<input class="form-control" type="text" id="post_slug" name="url" placeholder="Enter Url slug" value="<?php echo $row['url_slug']; ?>" readonly="readonly">
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label" for="val-select2">Select Exam Type<span class="text-danger">*</span></label>
<div class="col-md-10">
<select class="js-select2 form-control" id="type" name="exam_type" style="width: 100%;">
<option selected="selected" value="<?php echo $row['type_id']; ?>"><?php echo $row['type']; ?></option>
<option value="1">Central</option>
<option value="2">State</option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label" for="val-select2">Select Exam Category<span class="text-danger">*</span></label>
<div class="col-md-10">
<select class="js-select2 form-control" name="category" style="width: 100%;">
<?php
$sql = $db->prepare("SELECT cat_id,name FROM $TABLE_EXAM_CATEGORY");
$sql->execute();
?>
<option selected="selected" value="<?php echo $row['cat_id']; ?>"><?php echo $row['name']; ?></option>
<?php while ($row1 = $sql->fetch(PDO::FETCH_ASSOC)) { ?>
<option value="<?php echo $row1['cat_id']; ?>"><?php echo $row1['name']; ?></option>
<?php } ?>
</select>
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label" for="val-select2">Select State<span class="text-danger">*</span></label>
<div class="col-md-10">
<select class="js-select2 form-control" id="type2" name="state" style="width: 100%;">
<?php
$sql = $db->prepare("SELECT state_id,state_name FROM $TABLE_STATES");
$sql->execute();
?>
<option selected="selected" value="<?php echo $row['state_id']; ?>"><?php echo $row['state_name']; ?></option><?php while ($row2 = $sql->fetch(PDO::FETCH_ASSOC)) { ?>
<option value="<?php echo $row2['state_id']; ?>"><?php echo $row2['state_name']; ?></option>
<?php } ?>
</select>
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label" for="val-select2">Select State Commission<span class="text-danger">*</span></label>
<div class="col-md-10">
<select name="state_commission" class="form-control" id="statecommission">
<option selected="selected" value="<?php echo $row['state_commission']; ?>"><?php echo $row['comm_name']; ?></option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label" for="headTitle"> H1 Title</label>
<div class="col-md-10">
<input class="form-control" type="text" name="headTitle" placeholder="Enter Heading Title" value="<?php echo $row['h1_title']; ?>">
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label" for="metaTitle"> Meta Title</label>
<div class="col-md-10">
<input class="form-control" type="text" name="metaTitle" placeholder="Enter Meta Title" value="<?php echo $getMetaTitle['meta_value']; ?>">
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label" for="metafkeyword">Meta Focus Keyword</label>
<div class="col-md-10">
<input class="form-control" type="text" name="metafkeyword" placeholder="Enter Meta Focus Keyword" value="<?php echo $getMetaKey['meta_value']; ?>">
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label" for="metaKeyword">Meta Keyword</label>
<div class="col-md-10">
<input class="form-control" type="text" name="metaKeyword" placeholder="Enter Meta Keyword" value="<?php echo $getMetaKeyword['meta_value']; ?>">
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label" for="metaDesc">Meta Description</label>
<div class="col-md-10">
<input class="form-control" type="text" name="metaDesc" placeholder="Enter Meta Description" value="<?php echo $getMetaDesc['meta_value']; ?>">
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label" for="val-select2">Age<span class="text-danger">*</span></label>
<div class="col-md-2">
<input class="form-control" type="number" value="<?php echo $row['age_to']; ?>" name="age_to" placeholder="To">
</div>
<div class="col-md-2">
<input class="form-control" type="number" value="<?php echo $row['age_from']; ?>" name="age_from" placeholder="From">
</div>
<div class="col-md-6">
<input class="form-control" type="text" name="age_desc" placeholder="Age Description" value="<?php echo $row['age_desc']; ?>">
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label" for="val-select2">Qualification<span class="text-danger">*</span></label>
<div class="col-md-4">
<select class="js-select2 form-control" name="quali" style="width: 100%;">
<?php
$sql = $db->prepare("SELECT qualification_id,quali_name FROM $TABLE_QUALIFICATION order by display_order ASC");
$sql->execute();
?>
<option selected="selected" value="<?php echo $row['qualification_id']; ?>"><?php echo $row['quali_name']; ?></option> <?php while ($row4 = $sql->fetch(PDO::FETCH_ASSOC)) { ?>
<option value="<?php echo $row4['qualification_id']; ?>"><?php echo $row4['quali_name']; ?></option>
<?php } ?>
</select>
</div>
<div class="col-md-6">
<input class="form-control" type="text" name="quali_dis" placeholder="Qualification Description" value="<?php echo $row['qualification_desc']; ?>">
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label" for="val-select2">Physical Eligibility<span class="text-danger">*</span></label>
<div class="col-md-10">
<textarea class="ckeditor" name="physical" id="editor2"><?php echo $row['physical']; ?></textarea>
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label" for="val-confirm-password">Fees<span class="text-danger">*</span></label>
<div class="col-md-10">
<input class="form-control" type="number" name="fee_desc" value="<?php echo $row['fee']; ?>">
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label" for="val-confirm-password">Fee Description<span class="text-danger">*</span></label>
<div class="col-md-10">
<textarea class="ckeditor" name="fee" id="editor3"><?php echo $row['fee_desc']; ?></textarea>
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label" for="val-confirm-password">Exam Summary<span class="text-danger">*</span></label>
<div class="col-md-10">
<textarea class="ckeditor" name="summary" id="editor4"><?php echo $row['exam_summary']; ?></textarea>
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label" for="val-confirm-password">Important Notes<span class="text-danger">*</span></label>
<div class="col-md-10">
<textarea class="ckeditor" name="imp_notes" id="editor4"><?php echo $row['important_notes']; ?></textarea>
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label" for="val-confirm-password">Total Vacancy<span class="text-danger">*</span></label>
<div class="col-md-10">
<input class="form-control" type="number" name="vacancy" placeholder="" value="<?php echo $row['total_vacancy']; ?>">
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label" for="val-confirm-password"> Exam id<span class="text-danger">*</span></label>
<div class="col-md-10">
<input class="form-control" type="text" name="examid" placeholder="" value="<?php echo $row['sp_exam_id']; ?>">
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label" for="val-confirm-password">Total Time<span class="text-danger">*</span></label>
<div class="col-md-10">
<input class="form-control" type="text" name="total_time" placeholder="" value="<?php echo $row['total_time']; ?>">
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label" for="val-confirm-password">Total Marks<span class="text-danger">*</span></label>
<div class="col-md-10">
<input class="form-control" type="text" name="marks" placeholder="" value="<?php echo $row['total_marks']; ?>">
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label" for="val-confirm-password">Exam Mode<span class="text-danger">*</span></label>
<div class="col-md-10">
<input class="form-control" type="text" name="mode" placeholder="" value="<?php echo $row['exam_mode']; ?>">
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label" for="val-confirm-password">Negative Marking<span class="text-danger">*</span></label>
<div class="col-md-10">
<input class="form-control" type="text" name="marking" placeholder="" value="<?php echo $row['negative_marking']; ?>">
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label" for="val-confirm-password">Tabname<span class="text-danger">*</span></label>
<div class="col-md-10">
<input class="form-control" type="text" name="tabname" placeholder="" value="<?php echo $row['other_info_tabname']; ?>">
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label" for="val-confirm-password">Other Info<span class="text-danger">*</span></label>
<div class="col-md-10">
<textarea class="ckeditor" name="other_info" id="editor4"><?php echo $row['other_info']; ?></textarea>
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label" for="val-confirm-password">Official Website Link<span class="text-danger">*</span></label>
<div class="col-md-10">
<input class="form-control" type="text" name="link" placeholder="https://example.com" value="<?php echo $row['off_web_link']; ?>">
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label" for="val-confirm-password">Display order<span class="text-danger">*</span></label>
<div class="col-md-10">
<input class="form-control" type="number" name="order" placeholder="" value="<?php echo $row['display_order']; ?>">
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label" for="val-confirm-password">Top Display order<span class="text-danger">*</span></label>
<div class="col-md-10">
<input class="form-control" type="number" name="top_order" placeholder="" value="<?php echo $row['top_display_order']; ?>">
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label" for="val-confirm-password">Status<span class="text-danger">*</span></label>
<div class="col-md-10">
<select class="js-select2 form-control" name="status" style="width: 100%;">
<option selected="selected" value="<?php echo $row['status']; ?>"><?php echo $status; ?></option>
<option value="1">Active</option>
<option value="0">Deactive</option>
</select>
</div>
</div>
<div class="form-group">
<div class="col-md-10 col-md-offset-2">
<button class="btn btn-lg btn-primary" type="submit" name="submit">Submit</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</main>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#type2").change(function() {
var id = $(this).val();
var dataString = 'id=' + id;
$.ajax({
type: "POST",
url: "get_state_comm.php",
data: dataString,
cache: false,
success: function(html) {
$("#statecommission").html(html);
}
});
});
});
</script>
<script>
// to make slug from post name
function convertToSlug(str) {
str = str.replace(/[`~!@#$%^&*()_\-+=\[\]{};:'"\\|\/,.<>?\sāā//]/g, ' ').toLowerCase(); //replace all special characters | symbols with a space
str = str.replace(/^\s+|\s+$/gm, ''); // trim spaces at start and end of string
str = str.replace(/\s+/g, '-'); // replace space with dash/hyphen
document.getElementById("post_slug").value = str;
document.getElementById('post_slug').readOnly = true;
}
</script>
<?php include 'footer.php'; ?>