/home/hdwebsolution/public_html/ns-interior/admin-pages/add-news.php
<?php include('site-header.php'); ?>
<!-- end of LOGO CONTAINER -->
<!-- - - - - - - - - - - - - -->
<!-- start of SIDEBAR -->
<!-- - - - - - - - - - - - - -->
<?php include('left-nevigation.php'); ?>
<!-- - - - - - - - - - - - - -->
<!-- end of SIDEBAR -->
<!-- - - - - - - - - - - - - -->
<script src="ckeditor/ckeditor.js"></script>
<main id="playground">
<!-- - - - - - - - - - - - - -->
<!-- start of TOP NAVIGATION -->
<!-- - - - - - - - - - - - - -->
<?php include('site-top-header.php'); ?>
<!-- - - - - - - - - - - - - -->
<!-- end of TOP NAVIGATION -->
<!-- - - - - - - - - - - - - -->
<!-- PAGE TITLE -->
<?php
extract($_POST);
$tmp = $_FILES['att']['tmp_name'];
$fn = $_FILES['att']['name'];
$ext = explode(".",$fn);
$extt = end($ext);
$fnn = rand().".$extt";
if(isset($sub))
{
if($category_name!="select Category")
{
if($_FILES['att']['name']!="")
{
$pro_type = addslashes($pro_type);
$pro_name = $_POST['pro_name'];
$insert_Sql = "INSERT INTO `tbl_services_product1`(`pro_category`, `pro_name`, `pro_type`, `pro_offer`, `pro_desc`,`pro_brf` ,`pro_more`,`dp_rate`,`percentage` ,`pro_image`) VALUES ('$category_name','$pro_name','$pro_type','$pro_offer','$pro_desc','$pro_brf','$pro_more','$dp_rate','$percentage','$fnn')";
if(mysqli_query($link,$insert_Sql))
{
move_uploaded_file($tmp, "../product-image/$fnn");
$msg = "<p style='color:green;'>Save news Successfully!!!</p>";
}
}
else
{
$msg ="<p style='color:red;'>Choose Your Image!!!!</p>";
}
}
else
{
$msg ="<p style='color:red;'>Choose Your Category!!!!</p>";
}
}
?>
<!-- Updata Product -->
<?php
$id = mysqli_real_escape_string($link,$_GET['edit']);
if(isset($upd))
{
if($_FILES['att']['name']!="")
{
$pro_type = addslashes($pro_type);
$pro_name = $_POST['pro_name'];
$Update_Sql = "UPDATE `tbl_services_product1` SET
`pro_category`='$category_name',
`pro_name`='$pro_name',
`pro_type`='$pro_type',
`pro_offer`='$pro_offer',
`pro_desc`='$pro_desc',
`pro_more`='$pro_more',
`dp_rate`='$dp_rate',
`percentage`='$percentage',
`pro_brf`='$pro_brf',
`pro_image`='$fnn'
WHERE `pro_id`=$id";
if(mysqli_query($link,$Update_Sql))
{
unlink("../product-image/$himage");
move_uploaded_file($tmp, "../product-image/$fnn");
$msg = "<p style='color:green;'>Save news Successfully!!!</p>";
}
}
else
{
$pro_type = addslashes($pro_type);
$pro_name = $_POST['pro_name'];
$Update_Sql = "UPDATE `tbl_services_product1` SET
`pro_category`='$category_name',
`pro_name`='$pro_name',
`pro_type`='$pro_type',
`pro_offer`='$pro_offer',
`pro_desc`='$pro_desc',
`pro_more`='$pro_more',
`dp_rate`='$dp_rate',
`percentage`='$percentage',
`pro_brf`='$pro_brf'
WHERE `pro_id`=$id";
if(mysqli_query($link,$Update_Sql))
{
$msg = "<p style='color:green;'>Save news Successfully!!!</p>";
}
}
}
?>
<!-- Fetching these product -->
<?php
if(isset($_GET['edit']))
{
$sel = mysqli_query($link,"select * from tbl_services_product1 where pro_id=$id");
$arr = mysqli_fetch_assoc($sel);
$cat = $arr['pro_category'];
$sel1 = mysqli_query($link,"select * from tbl_services_category1 where cat_id=$cat");
$arr1 = mysqli_fetch_assoc($sel1);
}
?>
<section id="page-title" class="row">
<div class="col-md-8">
<h1>News</h1>
<p class="lead"><?php if($_GET['edit']==""){echo 'Add';}else{echo 'Update';}?>your News below</strong>.</p>
</div>
<div class="col-md-4">
</div>
</section>
<!-- / PAGE TITLE -->
<section>
<div class="container-fluid">
<div><label><?=@$msg;?></label></div>
<div class="row">
<form method="post" enctype="multipart/form-data">
<div class="col-md-12">
<a href="update-news.php#<?=$_GET['edit'];?>" class="btn btn-primary">Back</a>
</div>
<div class="col-md-12">
<div class="form-group">
<select class="form-control" name="category_name" style="display:none;" disabled>
<option value="2" selected>News</option>
</select>
<input type="hidden" name="category_name" value="2">
</div>
<div class="form-group">
<label>News Name:</label><br>
<input class="form-control" type="text" name="pro_name" value="<?=$arr['pro_name'];?>">
<input type="hidden" value="<?=$arr['pro_image']?>" name="himage">
<!-- <label>Image for Product Page (Size :234 X 234 pixels)</label> -->
<img src="../product-image/<?=$arr['pro_image'];?>" alt="" style="width:100px;height:100px;">
<input type="file" name="att" value="">
</div>
</div>
<div class="col-md-12">
<div class="form-group">
<label>Meta Ttile :</label>
<input type="text" class="form-control" name="pro_type" value="<?=$arr['pro_type'];?>">
</div>
<div class="form-group">
<label>Meta Description:</label>
<input type="text" class="form-control" name="dp_rate" value="<?=$arr['dp_rate'];?>">
</div>
<div class="form-group">
<label>Meta Keywords:</label>
<input type="text" class="form-control" name="percentage" value="<?=$arr['percentage'];?>">
</div>
</div>
</div>
<div class="col-md-12">
<div class="form-group">
<label>Quote</label>
<input type="text" name="pro_offer" value="<?=$arr['pro_offer'];?>" class="form-control">
</div>
</div>
<div class="col-lg-12">
<div class="form-group">
<label>Description:</label><br>
<textarea class="form-control" id="ckeditor2" name="pro_more" style="width:100%"><?=$arr['pro_more'];?></textarea>
</div>
</div>
<div class="col-md-12">
<div class="form-group">
<label>
Content :</label>
<textarea class="form-control" id="ckeditor1" name="pro_brf" style="width:100%"><?=$arr['pro_brf'];?></textarea>
</div>
</div>
<div class="col-md-12">
<div class="col-md-12">
<div class="form-group">
<label>URL Link:</label><br>
<textarea class="form-control" id="ckeditor2" name="pro_desc" style="width:100%"><?=$arr['pro_desc'];?></textarea>
</div>
</div>
<!-- <div class="col-md-6">
<div class="form-group">
<label>Applications :</label><br>
<textarea class="form-control" id="ckeditor3" name="pro_desc" style="width:100%"><?=$arr['pro_desc'];?></textarea>
</div>
</div> -->
</div>
<div class="col-md-4">
<br><br>
<div class="form-group">
<?php
if($_GET['edit']=="")
{
?>
<input class="btn btn-primary text-center" type="submit" name="sub" value="SUBMIT">
<?php
}
else
{
?>
<input class="btn btn-primary text-center" type="submit" name="upd" value="UPDATE">
<?php
}
?>
</div>
</div>
<div class="col-md-4">
</div>
</form>
</div>
</section>
<script>
CKEDITOR.replace(ckeditor1)
CKEDITOR.replace(ckeditor2)
CKEDITOR.replace(ckeditor3)
CKEDITOR.replace(ckeditor4)
</script>
<script src="ckeditor/ckeditor.js">
</script>
<!-- / container-fluid -->
<?php include('site-footer.php'); ?>