Index of /demo/uploads/SYS_CONFIG/riotsymlinkphp/gatividhiyaa_db_txt9134
<?php
include('config.php');
//Insert Data
if ($_POST['action'] == 'Save')
{
$gatividhi_name = $_POST['gatividhi_name'];
$gatividhi_desc= $_POST['gatividhi_desc'];
$gatividhi_date= $_POST['gatividhi_date'];
$type= $_POST['type'];
$tmp_image = $_FILES['gatividhi_image']['tmp_name'];
$extension = pathinfo($_FILES["gatividhi_image"]["name"], PATHINFO_EXTENSION);
$save_image = round(microtime(true)).".".$extension;
$allowTypes = array('jpg','jpeg','png','pdf');
if (in_array($extension, $allowTypes)) {
move_uploaded_file($tmp_image,"uploads/".$save_image);
$query = mysqli_query($mysqli,"insert into tbl_gatividhiyaan(title,description,type,date,img,page_id) values ('$gatividhi_name','$gatividhi_desc','$type','$gatividhi_date','$save_image','6') ");
if ($query) {
echo 'created';
}
else{
echo "error";
}
}
else{
echo 'error';
}
}
//Delete Data
if ($_POST['action'] =='delete')
{
$deleteImg = $_POST['deleteImg'];
$delteBtnId = $_POST['delteBtnId'];
$sql = mysqli_query($mysqli,"delete from tbl_gatividhiyaan where id = '".$delteBtnId."' and page_id='6' ");
if ($sql) {
unlink('uploads/'.$deleteImg);
echo 'deleted';
}
}
//fetch single row
if ($_POST['action'] =='fetchSingleRow') {
$output = array();
$editBtnId = $_POST['editBtnId'];
$result =mysqli_query($mysqli,"select * from tbl_gatividhiyaan where id= '".$editBtnId."' and page_id='6' ");
while ($rows = mysqli_fetch_array($result))
{
$output['gatividhi_image'] = $rows['img'];
$output['gatividhi_name'] = $rows['title'];
$output['gatividhi_desc'] = $rows['description'];
$output['gatividhi_date'] = $rows['date'];
$output['type'] = $rows['type'];
$output['uploaded_hidden_image'] = '<img width="70px" height="70px" src="uploads/'.$rows["img"].'">';
}
echo json_encode($output);
}
//Update data
if ($_POST['action'] =='Update') {
$updateId = $_POST['updateId'];
$uploaded_image = $_POST['uploaded_image'];
$new_image='';
$gatividhi_name = $_POST['gatividhi_name'];
$gatividhi_desc= $_POST['gatividhi_desc'];
$gatividhi_date= $_POST['gatividhi_date'];
// $type= $_POST['type'];
if ($_FILES['gatividhi_image']['name']!='') {
$tmp_image = $_FILES['gatividhi_image']['tmp_name'];
$extension = pathinfo($_FILES['gatividhi_image']['name'], PATHINFO_EXTENSION);
$new_image = round(microtime(true)).".".$extension;
move_uploaded_file($tmp_image,"uploads/".$new_image);
unlink('uploads/'.$uploaded_image);
}
else{
$new_image =$uploaded_image;
}
$update_sql = mysqli_query($mysqli,"update tbl_gatividhiyaan set title ='$gatividhi_name',description = '$gatividhi_desc',date='$gatividhi_date', img ='$new_image' where id = '".$updateId."' and page_id='6' ");
if ($update_sql) {
echo 'Update';
}
}
?>