HEX
Server: Apache/2.4.58 (Ubuntu)
System: Linux ip-172-31-18-78 6.17.0-1017-aws #17~24.04.1-Ubuntu SMP Tue May 26 21:09:53 UTC 2026 aarch64
User: ubuntu (1000)
PHP: 8.2.31
Disabled: NONE
Upload Files
File: /var/www/nclive/technc/edit_kvs_navodya_list.php
<?php
include 'header.php';

include '../wp-config.php';

$id = $_REQUEST['id'];

// ini_set('display_errors', 1);
// ini_set('display_startup_errors', 1);
// error_reporting(E_ALL);

$curDate = date('Y-m-d H:i:s');
$user_id = 1;
$message = '';  // for displayin error and success msgs

$TABLE_POST = 'naukri_wp_posts';
$TABLE_POSTMETA = 'naukri_wp_postmeta';
$TABLE_YOAST_INDEXABLE = 'naukri_wp_yoast_indexable';
$TABLE_KVS_NVS = 'sp_kvs_navodya';
$TABLE_STATES = 'sp_states';
$TABLE_CITY = 'sp_city';
$TABLE_EXAM_UPDATE = 'sp_exam_update';

$strreplace = array(" ", "&");
$replace = array("-", "-");

// get data as per id
$query = "SELECT t1.id, t1.type,t1.url_slug, t1.name, t1.state_id, t1.city_id,t1.pincode,t1.address, t1.longitude, t1.latitude,t1.important_emails, t1.important_phones, t1.official_website_link, t1.online_apply_link, t1.online_fee_link, t1.result_link, t1.other_info,t1.display_order, t1.status,t2.state_name ,t1.add_date,t3.city as city FROM  $TABLE_KVS_NVS as t1
LEFT JOIN $TABLE_STATES as t2 on t2.state_id=t1.state_id
LEFT JOIN $TABLE_CITY as t3 on t3.city_id=t1.city_id where id='$id'";
$sql = $db->prepare($query);
$sql->execute();
$row = $sql->fetch();

/*----------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();

if (isset($_REQUEST['update'])) {
	$id = $_REQUEST['id'];
	$type = $_REQUEST['types'];
	$name = $_REQUEST['unames'];
	$stateid = $_REQUEST['state'];
	$cityid = $_REQUEST['city'];
	$pin = $_REQUEST['pincodes'];
	$address = $_REQUEST['adds'];
	$longitude = $_REQUEST['longitudes'];
	$latitude = $_REQUEST['latitudes'];
	$emails = $_REQUEST['emailss'];
	$phones = $_REQUEST['phoness'];
	$weblink = $_REQUEST['links'];
	$applylink = $_REQUEST['applys'];
	$onlinefee = $_REQUEST['fees'];
	$result = $_REQUEST['results'];
	$other = $_REQUEST['others'];
	$display = $_REQUEST['orders'];
	$status = $_REQUEST['statuss'];

	$meta_title = $_REQUEST['metaTitle'];
	$meta_key = $_REQUEST['metafkeyword'];
	$meta_keyword = $_REQUEST['metaKeyword'];
	$meta_desc = $_REQUEST['metaDesc'];

	if ($_REQUEST['url_slug'] == '') {
		$url_slug = strtolower(str_replace($strreplace, $replace, $name));
	} else {
		$url_slug = $_REQUEST['url_slug'];
	}

	$query2 = "UPDATE $TABLE_KVS_NVS SET type = '$type',name = '$name', url_slug='$url_slug', state_id = '$stateid', city_id = '$cityid', pincode = '$pin', address = '$address', longitude = '$longitude', latitude = '$latitude', important_emails = '$emails', important_phones = '$phones', official_website_link = '$weblink', online_apply_link = '$applylink', online_fee_link = '$onlinefee', result_link = '$result', other_info = '$other',display_order = '$display', status = '$status' WHERE id = '$id'";
	$sql2 = $db->prepare($query2);
	$sql2->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);

	$query3 = "INSERT INTO $TABLE_EXAM_UPDATE SET `type`='U',`exam_id`='$id',`user_id`='$user_id',`date`='$curDate',`description`='$meta_desc'";
	$sqlur = $db->prepare($query3);
	$successResult = $sqlur->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>';
	}
}

?>
<script type="text/javascript" charset="utf8" src="https://code.jquery.com/jquery-3.3.1.js"></script>
<!--  -->
<main id="main-container">
	<div class="content content-narrow">
		<div class="row">
			<div class="col-lg-12">
				<!-- Bootstrap Forms Validation -->
				<h2 class="content-heading">KVS/NVS Navodya List</h2>
				<?php echo $message; ?>
				<div class="block">
					<div class="block-header">
						<form class="js-validation-bootstrap form-horizontal" action="" method="post" id="form">
							<div class="form-group">
								<label class="col-md-2 control-label" for="val-select2"> Type </label>
								<input type="hidden" value="<?php echo $row['id'] ?>" name="id">

								<div class="col-md-10">
									<select class="js-select2 form-control" name="types" style="width: 100%;">										
										<option value="KVS"<?php if ($row['type'] == 'KVS') { echo 'selected="selected"'; } ?>>KVS</option>
										<option value="NVS"<?php if ($row['type'] == 'NVS') { echo 'selected="selected"'; } ?>>NVS</option>
									</select>
								</div>
							</div>

							<div class="form-group">
								<label class="col-md-2 control-label" for="val-username">Name<span class="text-danger">*</span></label>
								<div class="col-md-10">
									<input class="form-control" type="text" name="unames" value="<?php echo $row['name'] ?>" placeholder="" onkeyup="convertToSlug(this.value)" onload="convertToSlug(this.value)" />
								</div>
							</div>
							<div class="form-group">
								<label class="col-md-2 control-label" for="val-url_slug">URL Slug<span class="text-danger">*</span></label>
								<div class="col-md-10">
									<input class="form-control" type="text" id="post_slug" name="url_slug" value="<?php echo $row['url_slug'] ?>" placeholder=""  readonly="readonly"/>
								</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">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 order by state_name asc");
										$sql->execute();
										?>
										<?php while ($row1 = $sql->fetch(PDO::FETCH_ASSOC)) {
											if ($row['state_id'] == $row1['state_id']) { ?>
												<option value="<?php echo $row['state_id']; ?>" selected="selected"><?php echo $row['state_name']; ?></option>
											<?php } else { ?>
												<option value="<?php echo $row1['state_id']; ?>"><?php echo $row1['state_name']; ?></option>
										<?php }
										} ?>
									</select>
								</div>
							</div>
							<div class="form-group">
								<label class="col-md-2 control-label" for="val-select2">Select City<span class="text-danger">*</span></label>
								<div class="col-md-10">
									<select name="city" class="form-control" id="city">
										<option value="<?php echo $row['city_id'] ?>" selected="selected"><?php echo $row['city'] ?></option>
										<option>Select City</option>
									</select>
								</div>
							</div>
							<div class="form-group">
								<label class="col-md-2 control-label" for="val-password">Pin Code<span class="text-danger">*</span></label>
								<div class="col-md-10">
									<input class="form-control" value="<?php echo $row['pincode'] ?>" type="text" name="pincodes" />
								</div>
							</div>

							<div class="form-group">
								<label class="col-md-2 control-label" for="val-password">Address<span class="text-danger">*</span></label>
								<div class="col-md-10">
									<input class="form-control" type="text" name="adds" value="<?php echo $row['address'] ?>" />
								</div>
							</div>

							<div class="form-group">
								<label class="col-md-2 control-label" for="val-password"> longitude<span class="text-danger">*</span></label>
								<div class="col-md-10">
									<input class="form-control" type="text" name="longitudes" value="<?php echo $row['longitude'] ?>">
								</div>
							</div>

							<div class="form-group">
								<label class="col-md-2 control-label" for="val-password">latitude<span class="text-danger">*</span></label>
								<div class="col-md-10">
									<input class="form-control" type="text" name="latitudes" value="<?php echo $row['latitude'] ?>">
								</div>
							</div>

							<div class="form-group">
								<label class="col-md-2 control-label" for="val-password">Important Emails<span class="text-danger">*</span></label>
								<div class="col-md-10">
									<input class="form-control" type="text" name="emailss" value="<?php echo $row['important_emails'] ?>">
								</div>
							</div>

							<div class="form-group">
								<label class="col-md-2 control-label" for="val-password">Important Phones<span class="text-danger">*</span></label>
								<div class="col-md-10">
									<input class="form-control" type="text" name="phoness" value="<?php echo $row['important_phones'] ?>">
								</div>
							</div>

							<div class="form-group">
								<label class="col-md-2 control-label" for="val-password">official Website Link<span class="text-danger">*</span></label>
								<div class="col-md-10">
									<input class="form-control" type="text" name="links" value="<?php echo $row['official_website_link'] ?>">
								</div>
							</div>

							<div class="form-group">
								<label class="col-md-2 control-label" for="val-password">Online Apply Link<span class="text-danger">*</span></label>
								<div class="col-md-10">
									<input class="form-control" type="url" name="applys" value="<?php echo $row['online_apply_link'] ?>">
								</div>
							</div>

							<div class="form-group">
								<label class="col-md-2 control-label" for="val-password">Online Fee Link<span class="text-danger">*</span></label>
								<div class="col-md-10">
									<input class="form-control" type="text" name="fees" value="<?php echo $row['online_fee_link'] ?>">
								</div>
							</div>

							<div class="form-group">
								<label class="col-md-2 control-label" for="val-password">Result link<span class="text-danger">*</span></label>
								<div class="col-md-10">
									<input class="form-control" type="text" name="results" value="<?php echo $row['result_link'] ?>">
								</div>
							</div>

							<div class="form-group">
								<label class="col-md-2 control-label" for="val-password">Other Info<span class="text-danger">*</span></label>
								<div class="col-md-10">
									<input class="form-control" type="text" name="others" value="<?php echo $row['other_info'] ?>">
								</div>
							</div>

							<div class="form-group">
								<label class="col-md-2 control-label" for="val-password">Display Order<span class="text-danger">*</span></label>
								<div class="col-md-10">
									<input class="form-control" type="number" name="orders" value="<?php echo $row['display_order'] ?>">
								</div>
							</div>

							<div class="form-group">
								<label class="col-md-2 control-label" for="val-password">Status<span class="text-danger">*</span></label>
								<div class="col-md-10">
									<select name="statuss" class="form-control">
										<?php if ($row['status'] == 1) { ?>
											<option value="1" selected="selected">Active</option>
											<option value="0">Deactive</option>
										<?php } else { ?>
											<option value="1">Active</option>
											<option value="0" selected="selected">Deactive</option>
										<?php } ?>
									</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="update">Submit</button>
								</div>
							</div>
						</form>
					</div>
				</div>
			</div>
		</div>
	</div>
</main>
<style type="text/css">
	.col-md-10 {
		width: 600px;
	}
</style>
<script type="text/javascript">
	$(document).ready(function() {
		$("#type2").change(function() {
			var id = $(this).val();
			var dataString = 'id=' + id;

			$.ajax({
				type: "POST",
				url: "get_city.php",
				data: dataString,
				cache: false,
				success: function(html) {
					$("#city").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'; ?>