File "page.php"
Full Path: /home/krishnamexports/public_html/panel/pages/page/page.php
File size: 7.14 KB
MIME-type: text/x-php; charset=us-ascii
Charset: utf-8
<?php
include_once("fckeditor/fckeditor.php");
if(isset($_POST['add']))
{
$parent_id = $_POST['parent_id'];
$name = $_POST['name'];
$page_order = $_POST['page_order'];
$page_banner = "";//rand().$_FILES['page_banner']['name'];
//move_uploaded_file($_FILES['page_banner']['tmp_name'],"pages/master/page/banner/".$page_banner);
$meta_title = $_POST['meta_title'];
$meta_description = $_POST['meta_description'];
$description = mysqli_real_escape_string($cn,$_POST['description']);
$slug_url = mysqli_real_escape_string($cn,$_POST['slug_url']);
$sqlSubject=mysqli_query ($cn, "insert into `tbl_page` set parent_id='$parent_id',name='$name', slug_url='$slug_url', page_order='$page_order',meta_title='$meta_title',meta_description='$meta_description', page_banner='".$page_banner."', description='$description'");
if($sqlSubject)
{
echo '<div class="alert alert-success"><strong>Success!</strong> Page Added Successfully.</div>';
}
else
{
echo '<div class="alert alert-danger"><strong>Danger!</strong> Page Not Exist.</div>';
}
}
if(isset($_POST['edit']))
{
$id = $_POST['id'];
$parent_id = $_POST['parent_id'];
$name = $_POST['name'];
$page_order = $_POST['page_order'];
$meta_title = $_POST['meta_title'];
$meta_description = $_POST['meta_description'];
$description = mysqli_real_escape_string($cn,$_POST['description']);
$slug_url = mysqli_real_escape_string($cn,$_POST['slug_url']);
$sql = mysqli_query($cn, "select * from tbl_page where id='$id'");
$sqlData = mysqli_fetch_array($sql);
/*if(!empty($_FILES['page_banner']['name']))
{
$page_banner = rand().$_FILES['page_banner']['name'];
move_uploaded_file($_FILES['page_banner']['tmp_name'],"pages/master/page/banner/".$page_banner);
}
else
{
$page_banner = $sqlData['page_banner'];
}*/
$page_banner ="";
$sqlSubject = mysqli_query ($cn,"update tbl_page SET parent_id='$parent_id',name='$name', slug_url='$slug_url', page_order='$page_order',meta_title='$meta_title',meta_description='$meta_description',page_banner='$page_banner',description='$description' where `id`='$id'");
if($sqlSubject)
{
echo '<div class="alert alert-success"><strong>Success!</strong> Parent Page Update Successfully.</div>';
}
else
{
echo '<div class="alert alert-success"><strong>Warrning!</strong> Not Updated try again.</div>';
}
}
if(isset($_GET['edit_id']))
{
$id = $_GET['edit_id'];
$sql = mysqli_query($cn, "select * from tbl_page where id='$id'");
$sqlData = mysqli_fetch_array ($sql);
}
?>
<div class="card">
<div class="card-body">
<h4 class="card-title">Add Page</h4>
<form class="forms-sample" method="post" enctype="multipart/form-data">
<div class="row">
<div class="col-md-4">
<div class="form-group">
<label for="exampleInputPassword4">Parent Page</label>
<select class="form-control" id="exampleFormControlSelect1" name="parent_id" required>
<option value="">Select Parent</option>
<option value="1" <?php if(isset($_GET['edit_id'])){ if($sqlData['parent_id']==1){ echo "selected";}}?>>Main Menu</option>
<option value="2" <?php if(isset($_GET['edit_id'])){ if($sqlData['parent_id']==2){ echo "selected";}}?>>Footer / Main Menu</option>
</select>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label for="exampleInputName1">Page Name</label>
<input type="hidden" class="tableName" value="tbl_page">
<input type="hidden" value="<?php if(isset($_GET['edit_id'])) {echo $sqlData['id'];}?>" name="id">
<input type="text" class="form-control setslugUrl" value="<?php if(isset($_GET['edit_id'])) {echo $sqlData['name'];}?>" name="name" id="exampleInputName1" placeholder="Page Name" autocomplete="off" required>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label for="exampleInputPassword4">Page Order</label>
<input type="text" class="form-control" name="page_order" value="<?php if(isset($_GET['edit_id'])) {echo $sqlData['page_order'];}?>" id="exampleInputPassword4" placeholder="Page Order">
</div>
</div>
</div>
<div class="row">
<div class="col-md-4">
<div class="form-group">
<label for="exampleInputPassword4">Meta Title</label>
<input type="text" class="form-control" name="meta_title" value="<?php if(isset($_GET['edit_id'])) {echo $sqlData['meta_title'];}?>" id="exampleInputPassword4" placeholder="Meta Title">
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label for="exampleInputPassword4">Meta Description</label>
<input type="text" class="form-control" name="meta_description" value="<?php if(isset($_GET['edit_id'])) {echo $sqlData['meta_description'];}?>" id="exampleInputPassword4" placeholder="Meta Description">
</div>
</div>
<!--<div class="col-md-4">
<div class="form-group">
<label for="exampleInputPassword4">Page Banner</label>
<input type="file" class="form-control" name="page_banner" <?php if(isset($_GET['edit_id'])){}else{?>required<?php }?>>
</div>
</div>-->
</div>
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label for="exampleInputName1">Slug Url</label>
<input type="text" class="form-control slugUrl" value="<?php if(isset($_GET['edit_id'])) {echo $sqlData['slug_url'];}?>" name="slug_url" id="exampleInputName1" placeholder="Slug Url" autocomplete="off" required>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label for="exampleInputCity1">Page Description</label>
<?php
$oFCKeditor = new FCKeditor('description');
$oFCKeditor->BasePath = 'fckeditor/';
//set the EnterMode to "br" (overwrites the default configuration from fckconfig.js)
$oFCKeditor->Config['EnterMode'] = 'br';
$oFCKeditor->Value = "";
if(isset($_REQUEST['edit_id'])){
$oFCKeditor->Value = $sqlData['description'];
}
$oFCKeditor->Create() ;
?>
</div>
</div>
</div>
<button type="submit" class="btn btn-success mr-2" name="<?php if(isset($_GET['edit_id'])) {echo "edit";}else{ echo "add";}?>">Submit</button>
</form>
</div>
</div>
<br><br>