%PDF- %GIF98; %PNG;
Server : ApacheSystem : Linux sh00666.bluehost.com 5.14.0-687.26.1.el9_8.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Jul 14 16:32:02 EDT 2026 x86_64 User : ndkhermy ( 1200) PHP Version : 8.5.12 Disable Function : NONE Directory : /home1/ndkhermy/www/website_6031bb72/admin/manage_hospital/ |
Upload File : |
<?php
error_reporting(0);
include("../function.php");
if($_SESSION['admin_id']==""){
header('location:../login.php');
}
$login_tbl=mysqli_fetch_array(mysqli_query($conn,"SELECT * FROM admin WHERE admin_id='".$_SESSION['admin_id']."'"));
// Sidebar strat
include('../include/sidebar.php');
// Sidebar wrap
$id=$_GET['id'];
?>
<!-- [ Main Content ] start -->
<section class="pcoded-main-container">
<div class="pcoded-content">
<!-- [ breadcrumb ] start -->
<div class="page-header">
<div class="page-block">
<div class="row align-items-center">
<div class="col-md-12">
<div class="page-header-title">
<div class="card-header d-flex justify-content-between">
<button class="btn btn-dark text-light fw-bold btn-sm btn-round has-ripple"><i class="feather icon-edit"></i> Add | Edit | Hospital </button>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- [ breadcrumb ] end -->
<!-- [ Main Content ] start -->
<div class="row">
<div class="col-md-12">
<div class="card">
<!-- <div class="card-header d-flex justify-content-between">
</div> -->
<div class="card-body">
<?php if(isset($_SESSION['otp_message'])){
echo '<div class="alert alert-success alert-dismissible fade show" role="alert">
<strong class="text-dark">'.$_SESSION['otp_message'].'</strong>
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close">
</button>
</div>';
}
unset($_SESSION['otp_message']);
?>
<?php
$fetQuery=mysqli_fetch_array(mysqli_query($conn,"SELECT * FROM `hospitals_tbl` WHERE id='$id'"));
?>
<form method="post" action="" enctype="multipart/form-data" autocomplete="off">
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label class="form-label" for="country_id">Country</label>
<select class="form-select" name="country_id" required>
<option value="">Please select Country</option>
<?php
$CatQry=mysqli_query($conn,"SELECT * FROM destination_tbl ORDER BY ID DESC");
while($row=mysqli_fetch_array($CatQry)){
?>
<option value="<?=$row['id']?>" <?=($fetQuery['country_id']==$row['id'])?'selected':'';?>><?=$row['title']?></option>
<?php } ;?>
</select>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label class="form-label" for="Whatsapp_Number">Whatsapp Number</label>
<input type="text" name="whatsapp_number" class="form-control" value="<?php if($id!=''){echo $fetQuery['whatsapp_number'];} ?>" required>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label class="form-label" for="title">Name</label>
<input type="text" name="title" class="form-control" value="<?php if($id!=''){echo $fetQuery['title'];} ?>" required>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label class="form-label" for="title">Name Arabic</label>
<input type="text" name="title_ar" class="form-control" value="<?php if($id!=''){echo $fetQuery['title_ar'];} ?>" required>
</div>
</div>
<!--<div class="col-md-6">
<div class="form-group">
<label class="form-label" for="Location">Location</label>
<textarea rows="3" name="location" class="form-control"> <?php if($id!=''){echo $fetQuery['location'];} ?></textarea>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label class="form-label" for="Location_Arabic">Location Arabic</label>
<textarea rows="3" name="location_ar" class="form-control"> <?php if($id!=''){echo $fetQuery['location_ar'];} ?></textarea>
</div>
</div>
<div class="col-md-6 d-none">
<div class="form-group">
<label class="form-label" for="Location_Link">Location Link</label>
<textarea rows="3" name="location_link" class="form-control"> <?php if($id!=''){echo $fetQuery['location_link'];} ?></textarea>
</div>
</div>
<div class="col-md-12">
<div class="form-group">
<label class="form-label" for="Website_Link">Website Link</label>
<textarea rows="2" name="website_link" class="form-control"> <?php if($id!=''){echo $fetQuery['website_link'];} ?></textarea>
</div>
</div>-->
<div class="col-md-6">
<div class="form-group">
<label class="form-label" for="title">Image1</label>
<input type="file" name="image1" class="form-control">
</div>
<?php if($id!=''){ ?>
<img src="<?=$base_url?>images/Upload/hospital/<?=$fetQuery["image1"];?>" style="width:100px; margin:8px;">
<?php } ?>
</div>
<div class="col-md-6">
<div class="form-group">
<label class="form-label" for="status">Status</label>
<select class="form-select" name="status" required>
<option value="1" <?=($fetQuery['status']=='1')?'selected':'';?>>Show</option>
<option value="0" <?=($fetQuery['status']=='0')?'selected':'';?>>Hide</option>
</select>
</div>
</div>
</div>
<div class="row">
<div class="col-md-6">
<?php
if(($id!='')){
echo'<input type="submit" name="update" class="btn btn-success" value="Update">';
}else{
echo'<input type="submit" name="add" class="btn btn-success" value="Add">';
}
?>
<a class="btn btn-dark text-white" href="show.php?page=hospi">Back</a>
</div>
</div>
</form>
</div>
</div>
</div>
<!-- [ form-element ] end -->
</div>
<!-- [ Main Content ] end -->
</div>
</section>
<?php include('../include/footer.php'); ?>
<!-- Insert data start --->
<?php
if(isset($_POST['add'])){
$country_id=$_POST['country_id'];
$title=str_replace("'", "\'", $_POST['title']);
$title_ar=str_replace("'", "\'", $_POST['title_ar']);
$location=str_replace("'", "\'", $_POST['location']);
$location_ar=str_replace("'", "\'", $_POST['location_ar']);
$location_link=str_replace("'", "\'", $_POST['location_link']);
$website_link=str_replace("'", "\'", $_POST['website_link']);
$whatsapp_number=str_replace("'", "\'", $_POST['whatsapp_number']);
$status=$_POST['status'];
$file_name = $_FILES['image1']['name'];
$file_tmp = $_FILES['image1']['tmp_name'];
$file_ext = strtolower(end(explode('.',$file_name)));
$random_number = rand(111111111, 999999999);
$new_file_name = $random_number . '.' . $file_ext;
$file_path = "../../images/Upload/hospital/" . $new_file_name;
move_uploaded_file($file_tmp, $file_path);
$addQry=mysqli_query($conn,
"INSERT `hospitals_tbl` SET
`country_id`='$country_id',
`title`='$title',
`title_ar`='$title_ar',
`location`='$location',
`location_ar`='$location_ar',
`location_link`='$location_link',
`website_link`='$website_link',
`whatsapp_number`='$whatsapp_number',
`status`='$status'")or die(mysqli_error($conn));
if($addQry){
echo "<script>window.location='show.php?page=hospi';</script>";
$_SESSION['message']="Record Added successfully";
}
}
?>
<!-- Insert data warp --->
<!-- Update data start --->
<?php
if(isset($_POST['update'])){
$country_id=$_POST['country_id'];
$title=str_replace("'", "\'", $_POST['title']);
$title_ar=str_replace("'", "\'", $_POST['title_ar']);
$location=str_replace("'", "\'", $_POST['location']);
$location_ar=str_replace("'", "\'", $_POST['location_ar']);
$location_link=str_replace("'", "\'", $_POST['location_link']);
$website_link=str_replace("'", "\'", $_POST['website_link']);
$whatsapp_number=str_replace("'", "\'", $_POST['whatsapp_number']);
$status=$_POST['status'];
$file_name = $_FILES['image1']['name'];
if(!empty($file_name)){
$file_tmp = $_FILES['image1']['tmp_name'];
$file_ext = strtolower(end(explode('.',$file_name)));
$random_number = rand(111111111, 999999999);
$new_file_name = $random_number . '.' . $file_ext;
$file_path = "../../images/Upload/hospital/" . $new_file_name;
$dl=mysqli_fetch_array(mysqli_query($conn,"SELECT * FROM `hospitals_tbl` WHERE id='$id'"));
if($dl)
{
unlink('../../images/Upload/hospital/'.$dl['image1']);
}
move_uploaded_file($file_tmp, $file_path);
mysqli_query($conn,"UPDATE `hospitals_tbl` SET `image1`='$new_file_name' WHERE id='$id'");
}
$editQry=mysqli_query($conn,"UPDATE `hospitals_tbl` SET
`country_id`='$country_id',
`title`='$title',
`title_ar`='$title_ar',
`location`='$location',
`location_ar`='$location_ar',
`location_link`='$location_link',
`website_link`='$website_link',
`whatsapp_number`='$whatsapp_number',
`status`='$status' WHERE id='$id'")or die(mysqli_error($conn));
if($editQry){
echo "<script>window.location='show.php?page=hospi';</script>";
$_SESSION['message']="Record Updated successfully";
}
}
?>
<!-- Update data warp --->