D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
u935876328
/
domains
/
ggcp.org.in
/
public_html
/
admin
/
Filename :
servicePage.php
back
Copy
<?php include('config.php'); include('header.php'); $serviceFile = "upload/service/"; $arr_aboutPageBannerSql = []; $arr_aboutPageDescSql = []; $arr_serviceSql = []; $aboutPageBannerSql = mysqli_query($db, "SELECT * FROM service_page_banner order by id DESC LIMIT 1"); $arr_aboutPageBannerSql = $aboutPageBannerSql->fetch_all(MYSQLI_ASSOC); $aboutPageDescSql = mysqli_query($db, "SELECT * FROM service_page_description order by id DESC LIMIT 1"); $arr_aboutPageDescSql = $aboutPageDescSql->fetch_all(MYSQLI_ASSOC); $serviceSql = mysqli_query($db, "SELECT * FROM services order by id"); $arr_serviceSql = $serviceSql->fetch_all(MYSQLI_ASSOC); if (isset($_POST['upload'])) { $filename = $_FILES["uploadfile"]["name"]; $tempname = $_FILES["uploadfile"]["tmp_name"]; $ext = pathinfo($filename, PATHINFO_EXTENSION); $newfilename = date('dmYHis') . "." . $ext; $folder = $serviceFile . $newfilename; $title = $_POST["title"]; if (!empty($arr_aboutPageBannerSql)){ // Get field information for all fields $hbid = "0"; $hbid = $arr_aboutPageBannerSql[0]['id']; if($filename == null){ $newfilename = $arr_aboutPageBannerSql[0]['filename']; } $result = mysqli_query($db, "UPDATE service_page_banner SET title=\"$title\", filename=\"$newfilename\" WHERE id=\"$hbid\""); } else { mysqli_query($db, "INSERT INTO service_page_banner (title,filename,youtube_id) VALUES (\"$title\",\"$newfilename\",\"-\")"); } // Now let's move the uploaded image into the folder: image if (move_uploaded_file($tempname, $folder)) { $msg = "Image uploaded successfully"; } else { $msg = "Failed to upload image"; } $aboutPageBannerSql = mysqli_query($db, "SELECT * FROM service_page_banner order by id DESC LIMIT 1"); $arr_aboutPageBannerSql = $aboutPageBannerSql->fetch_all(MYSQLI_ASSOC); } if (isset($_POST['about'])) { $aboutDesc = $_POST["aboutDesc"]; if (!empty($arr_aboutPageDescSql)){ // Get field information for all fields $id = $arr_aboutPageDescSql[0]['id']; mysqli_query($db, "UPDATE service_page_description SET description=\"$aboutDesc\" WHERE id=\"$id\""); } else { mysqli_query($db, "INSERT INTO service_page_description (description) VALUES (\"$aboutDesc\")"); } $aboutPageDescSql = mysqli_query($db, "SELECT * FROM service_page_description order by id DESC LIMIT 1"); $arr_aboutPageDescSql = $aboutPageDescSql->fetch_all(MYSQLI_ASSOC); } if (isset($_POST['addService'])) { $filename = $_FILES["uploadfile"]["name"]; $tempname = $_FILES["uploadfile"]["tmp_name"]; $ext = pathinfo($filename, PATHINFO_EXTENSION); $newfilename = date('dmYHis') . "." . $ext; $folder = $serviceFile . $newfilename; $title = $_POST["title"]; $description = $_POST["description"]; mysqli_query($db, "INSERT INTO services (title,filename,description) VALUES (\"$title\",\"$newfilename\",\"$description\")"); // Now let's move the uploaded image into the folder: image if (move_uploaded_file($tempname, $folder)) { $msg = "Image uploaded successfully"; } else { $msg = "Failed to upload image"; } $serviceSql = mysqli_query($db, "SELECT * FROM services order by id DESC LIMIT 1"); $arr_serviceSql = $serviceSql->fetch_all(MYSQLI_ASSOC); } if (isset($_POST['updateService'])) { $filename = $_FILES["uploadfile"]["name"]; $tempname = $_FILES["uploadfile"]["tmp_name"]; $ext = pathinfo($filename, PATHINFO_EXTENSION); $newfilename = date('dmYHis') . "." . $ext; $folder = $serviceFile . $newfilename; $id = $_POST["id"]; $title = $_POST["title"]; $description = $_POST["description"]; if($filename == null){ mysqli_query($db, "UPDATE services SET title=\"$title\", description=\"$description\" WHERE id=\"$id\""); }else{ mysqli_query($db, "UPDATE services SET title=\"$title\", filename=\"$newfilename\", description=\"$description\" WHERE id=\"$id\""); } // Now let's move the uploaded image into the folder: image if (move_uploaded_file($tempname, $folder)) { $msg = "Image uploaded successfully"; } else { $msg = "Failed to upload image"; } } if(isset($_POST['deleteService'])){ $id = $_POST['delete']; $sql = "DELETE FROM services WHERE id='$id'"; $result = $db->query($sql); } ?> <!DOCTYPE html> <html> <body> <!-- End Navbar --> <div class="content"> <div class="container-fluid"> <h2>Service Page</h2> <div class="row"> <div class="col-md-12"> <div class="card"> <div class="card-header card-header-primary" style="background: #71774b;"> <h4 class="card-title">Banner & Banner Youtube video</h4> <p class="card-category">Add Or Update Banner & Banner Youtube video !!!</p> </div> <div class="card-body"> <div class="row"> <div class="col-md-5 col-sm-12 col-xs-12"> <form method="POST" action="" enctype="multipart/form-data"> <div class="row"> <div class="col-md-12 col-sm-12 col-xs-12"> <div class="form-group"> <label class="bmd-label-floating">Title</label> <?php if (!empty($arr_aboutPageBannerSql)){ $title = $arr_aboutPageBannerSql[0]['title']; ?> <input type="text" name="title" class="form-control" value="<?php echo $title ?>" required> <?php } else { ?> <input type="text" name="title" class="form-control" required> <?php } ?> </div> </div> <div class="col-md-12 col-sm-12 col-xs-12"> <label class="bmd-label-floating">Banner Image</label><br> <input type="file" name="uploadfile" value="" /> </div> <div class="col-md-12 col-sm-12 col-xs-12"> <button type="submit" name="upload" class="btn btn-primary btn-sm btn-block waves-effect text-center m-b-20">Save</button> </div> </div> </form> </div> <div class="col-md-7 col-sm-12 col-xs-12" style="text-align: center;"> <?php if (!empty($arr_aboutPageBannerSql)){ $filename = ""; $filename = $arr_aboutPageBannerSql[0]['filename']; ?> <img src="<?php echo $serviceFile.$filename ?>" height="150px"> <?php } ?> </div> </div> </div> </div> </div> </div> <div class="row"> <div class="col-md-12"> <div class="card"> <div class="card-header card-header-primary" style="background: #71774b;"> <h4 class="card-title">Service Description</h4> <p class="card-category">Add Or Update Service Description !!!</p> </div> <div class="card-body"> <div class="row"> <div class="col-md-12 col-sm-12 col-xs-12"> <form method="POST" action="" enctype="multipart/form-data"> <div class="row"> <div class="col-md-12 col-sm-12 col-xs-12"> <div class="form-group"> <label class="bmd-label-floating">Description</label> <?php if (!empty($arr_aboutPageDescSql)){ $description = $arr_aboutPageDescSql[0]['description']; ?> <textarea class="form-control" name="aboutDesc" rows="10"><?php echo $description ?></textarea> <?php } else { ?> <textarea class="form-control" name="aboutDesc" rows="10"></textarea> <?php } ?> </div> </div> <div class="col-md-3 col-sm-12 col-xs-12"> <button type="submit" name="about" class="btn btn-primary btn-sm btn-block waves-effect text-center m-b-20">Save</button> </div> </div> </form> </div> </div> </div> </div> </div> </div> <div class="row"> <div class="col-md-12"> <div class="card"> <div class="card-header card-header-primary" style="background: #71774b;"> <h4 class="card-title">Service(s)</h4> <p class="card-category">Add new Service !!!</p> </div> <div class="card-body"> <div class="row"> <div class="col-md-12 col-sm-12 col-xs-12"> <form method="POST" action="" enctype="multipart/form-data"> <div class="row"> <div class="col-md-6 col-sm-12 col-xs-12"> <div class="form-group"> <label class="bmd-label-floating">Title</label> <input type="text" name="title" class="form-control" required> </div> </div> <div class="col-md-6 col-sm-12 col-xs-12"> <label class="bmd-label-floating">Image</label><br> <input type="file" name="uploadfile" value="" /> </div> <div class="col-md-12 col-sm-12 col-xs-12"> <div class="form-group"> <label class="bmd-label-floating">Description</label> <textarea name="description" class="form-control" rows="5" required></textarea> </div> </div> <div class="col-md-3 col-sm-12 col-xs-12"> <button type="submit" name="addService" class="btn btn-primary btn-sm btn-block waves-effect text-center m-b-20">Add</button> </div> </div> </form> </div> </div> </div> </div> </div> </div> <?php $serviceSql = mysqli_query($db, "SELECT * FROM services order by id"); $arr_serviceSql = $serviceSql->fetch_all(MYSQLI_ASSOC); if (!empty($arr_serviceSql)) { foreach ($arr_serviceSql as $ser) { ?> <div class="row"> <div class="col-md-12"> <div class="card"> <div class="card-header card-header-primary" style="background: #71774b;"> <h4 class="card-title"><?php echo $ser['title']?></h4> <p class="card-category">Add new Service !!!</p> </div> <div class="card-body"> <div class="row"> <div class="col-md-6 col-sm-12 col-xs-12"> <form method="POST" action="" enctype="multipart/form-data"> <input type="hidden" name="id" class="form-control" value="<?php echo $ser['id']?>" required> <div class="row"> <div class="col-md-12 col-sm-12 col-xs-12"> <div class="form-group"> <label class="bmd-label-floating">Title</label> <input type="text" name="title" class="form-control" value="<?php echo $ser['title']?>" required> </div> </div> <div class="col-md-12 col-sm-12 col-xs-12"> <div class="form-group"> <label class="bmd-label-floating">Description</label> <textarea name="description" class="form-control" rows="5" required><?php echo $ser['description']?></textarea> </div> </div> <div class="col-md-12 col-sm-12 col-xs-12"> <label class="bmd-label-floating">Image</label><br> <input type="file" name="uploadfile" value="" /> </div> <div class="col-md-6 col-sm-12 col-xs-12"> <button type="submit" name="updateService" class="btn btn-primary btn-sm btn-block waves-effect text-center m-b-20">Add</button> </div> <div class="col-md-6 col-sm-12 col-xs-12"> <form method="post" action=""> <input type="hidden" name="delete" value="<?php echo $ser['id']; ?>"> <input name="deleteService" type="submit" value="Delete" class="btn btn-danger btn-sm btn-block waves-effect text-center" /> </form> </div> </div> </form> </div> <div class="col-md-6 col-sm-12 col-xs-12" style="text-align: center;"> <img src="<?php echo $serviceFile.$ser['filename'] ?>" height="150px"> </div> </div> </div> </div> </div> </div> <?php } } ?> </div> </div> </div> <?php include('footer.php'); ?>