hjkhhrterwefdgdfgdfgdfgdgdfgdfgdsvstertrt
bnmbertsdfsdfgdfgdfgfffdgdfgdfgrtdfg
/
home
/
u254050281
/
domains
/
indiannadarcouncil.in
/
public_html
/
apanel
/
Upload FileeE
HOME
<?php session_start(); if(!isset($_SESSION['loginid']) && !isset($_SESSION['UserName'])){ header("Location:index.php"); } include("leftmenu.php"); include("db.php"); $name=$img=$date=$desc=$id=""; if(isset($_REQUEST["id"]) && $_REQUEST["id"] == 'Edit' && isset($_REQUEST["action"]) && $_REQUEST["action"] == 'Edit') { $id=$_GET['id']; $sql="SELECT * FROM blogs WHERE id=$id"; $res=mysqli_query($db,$sql); $rec=mysqli_fetch_assoc($res); $id=$rec['id']; $name=$rec['name']; $img=$rec['blog_image']; $desc=$rec['description']; $date=$rec['date']; } if(isset($_POST['submit'])){ $name=$_POST['name']; $desc=$_POST['description']; $date=$_POST['date']; $folder = "images/blogs/"; $img_file=$_FILES['image']['name']; if($img_file != '' && $img_file != NULL) { $file = $_FILES['image']['tmp_name']; $path = $folder . $img_file; $target_file=$folder.basename($img_file); $FileType=pathinfo($target_file,PATHINFO_EXTENSION); //Allow only JPG, JPEG, PNG & GIF etc formats if($FileType != "jpg" && $FileType != "png" && $FileType != "jpeg" && $FileType != "gif" ) { $error[] = 'Sorry, only JPEG,JPG AND PNG images are allowed'; } // move image in folder move_uploaded_file($file,$target_file); } if($id==""){ $query="INSERT INTO blogs(name,description,blog_image,date)VALUES('$name','$desc','$img_file','$date')"; }else{ if($img_file != '' && $img_file != NULL) { $fileupd=$img_file; } else { $fileupd=$img; } $query="UPDATE blogs SET name='$name',blog_image='$fileupd',description='$desc',date='$date' WHERE id=$id"; } $result=mysqli_query($db,$query); if($result){ $_SESSION['add_msg']="<h5 id='success_message' style='color:green;padding:10px;text-align:center;'>Blog Details Saved Successfully</h5>"; }else{ echo "Error"; } } ?> <!-- Content Wrapper. Contains page content --> <div class="content-wrapper"> <!-- Content Header (Page header) --> <section class="content-header"> <div class="container-fluid"> <div class="row mb-2"> <div class="col-sm-6"> <h1>Blog</h1> </div> <div class="col-sm-6"> <ol class="breadcrumb float-sm-right"> <li class="breadcrumb-item"><a href="dashboard.php">Home</a></li> <li class="breadcrumb-item active">Add Blog</li> </ol> </div> </div> </div><!-- /.container-fluid --> </section> <!-- Main content --> <section class="content"> <div class="container-fluid"> <!-- SELECT2 EXAMPLE --> <div class="card card-primary"> <div class="card-header"> <h3 class="card-title">Blog</h3> <div class="card-tools"> <a href="view-blog.php"><button type="button" class="btn btn-warning">View Blog</button></a> </div> </div> <!-- /.card-header --> <form id="quickForm" method="POST" autocomplete="off" action="" enctype="multipart/form-data" > <?php if(isset($_SESSION['add_msg'])){ echo $_SESSION['add_msg']; unset($_SESSION['add_msg']); } ?> <div class="card-body"> <div class="row"> <div class="form-group col-lg-4 col-md-4"> <label>Name</label> <input type="hidden" name="id" id="id" value="<?php echo $id;?>"> <input type="text" class="form-control" name="name" id="name" placeholder="Enter the Name" value="<?php echo $name; ?>" required> </div> <div class="form-group col-lg-4 col-md-4"> <label for="blog_img">Blog Image</label> <input type="file" name="image" id="image" class="form-control" <?php if(isset($_REQUEST["id"]) && $_REQUEST["id"] == 'Edit' && isset($_REQUEST["action"]) && $_REQUEST["action"] == 'Edit') { echo "";}else{echo "required";} ?>> <?php echo $img; ?> </div> <div class="form-group col-lg-4 col-md-4"> <label>Date</label> <input type="date" class="form-control" name="date" id="date" placeholder="Enter the Date" value="<?php echo $date; ?>" required> </div> </div> <div class="form-group col-lg-12 col-md-12"> <label>Description</label> <textarea class="form-control" name="description" id="description" placeholder="Enter the Description" value="" required><?php echo $desc; ?></textarea> </div> </div> <!-- /.row --> <!-- /.row --> </div> <!-- /.card-body --> <div class="card-footer"> <button type="submit" name="submit" class="btn btn-primary">Submit</button> <a href=""><button type="button" class="btn btn-danger">Cancel</button></a> </div> </form> </div> <!-- /.card --> <!-- SELECT2 EXAMPLE --> <!-- /.card --> <!-- /.card --> <!-- /.row --> <!-- /.row --> <!-- /.row --> </div> <!-- /.container-fluid --> </section> <!-- /.content --> </div> <!-- /.content-wrapper --> <?php include("footer.php"); ?> <script> $('#success_message').fadeIn().html(); setTimeout(function() { $('#success_message').fadeOut("slow"); }, 3000 ); </script> <script src="https://cdn.ckeditor.com/4.24.0-lts/standard/ckeditor.js"></script> <script> CKEDITOR.replace('description'); </script>