Mini Shell
<!DOCTYPE html>
<html lang="en">
<head>
<?php include('include/head_admin.php');
$page_id = '19';
$image = '';
$image_alt_tag = '';
$description = '';
if (isset($_GET['id']) && $_GET['id'] != '') {
$id = get_safe_value($con, $_GET['id']);
$image_required = '';
$res = mysqli_query($con, "select * from rental where id='$id'");
$check = mysqli_num_rows($res);
if ($check > 0) {
$row = mysqli_fetch_assoc($res);
$image = $row['image'];
$image_alt_tag = $row['image_alt_tag'];
$description = $row['description'];
} else {
header('location:rental.php');
die();
}
}
if (isset($_POST['submit_rental'])) {
// prx($_POST);
$image_alt_tag = get_safe_value($con, $_POST['image_alt_tag']);
$description = get_safe_value($con, $_POST['description']);
if (isset($_GET['id']) && $_GET['id'] == 0) {
if ($_FILES['image']['type'] != 'image/png' && $_FILES['image']['type'] != 'image/jpg' && $_FILES['image']['type'] != 'image/jpeg' && $_FILES['image']['type'] != 'image/webp') {
$msg = "Please select only png, jpg, webp and jpeg image format";
}
} else {
if ($_FILES['image']['type'] != '') {
if ($_FILES['image']['type'] != 'image/png' && $_FILES['image']['type'] != 'image/jpg' && $_FILES['image']['type'] != 'image/jpeg' && $_FILES['image']['type'] != 'image/jpeg') {
$msg = "Please select only png, jpg, webp and jpeg image format";
}
}
}
$msg = "";
if ($msg == '') {
if (isset($_GET['id']) && $_GET['id'] != '') {
if ($_FILES['image']['name'] != '') {
$image = $_FILES['image']['name'];
move_uploaded_file($_FILES['image']['tmp_name'], "../media/rental/" . $image);
mysqli_query($con, "UPDATE `rental` SET `image`='$image',`image_alt_tag`='$image_alt_tag', `description`='$description' WHERE `id`='$id'");
} else {
$update_query = "UPDATE `rental` SET `image`='$image',`image_alt_tag`='$image_alt_tag', `description`='$description' WHERE `id`='$id'";
mysqli_query($con, $update_query);
}
} else {
$image = rand(111111111, 999999999) . '_' . $_FILES['image']['name'];
move_uploaded_file($_FILES['image']['tmp_name'], "../media/rental/" . $image);
$insert_query = "INSERT INTO `rental` (`image`, `image_alt_tag`, `description`)
VALUES ('$image', '$image_alt_tag', '$description')";
mysqli_query($con, $insert_query);
print_r($insert_query);
}
header('location:rental.php');
die();
}
}
?>
</head>
<body>
<!--== MAIN CONTRAINER ==-->
<?php include('include/header_admin.php'); ?>
<!--== BODY CONTNAINER ==-->
<div class="container-fluid sb2">
<div class="row">
<?php include('include/sidebar_admin.php'); ?>
<div class="sb2-2">
<div class="sb2-2-2">
<ul>
<li><a href="index.php"><i class="fa fa-home" aria-hidden="true"></i> Home</a>
</li>
<!-- <li class="page-back"><a href="index.php"><i class="fa fa-backward" aria-hidden="true"></i> Back</a>
</li> -->
</ul>
</div>
<div class="sb2-2-add-about sb2-2-1">
<div class="box-inn-sp">
<div class="bor">
<form method="post" enctype="multipart/form-data">
<div class="row">
<div class="input-field col s12">
<div class="file-field">
<div class="btn">
<span>File</span>
<input type="file" name="image" value="<?php echo $image ?>">
</div>
<div class="file-path-wrapper">
<input class="file-path validate" type="text" name="image" placeholder="Upload Rental Image" value="<?php echo $image ?>">
</div>
</div>
<?php
if ($image != '') {
echo "<a target='_blank' href='" . "../media/rental/" . $image . "'><img width='150px' src='" . "../media/rental/" . $image . "'/></a>";
}
?>
</div>
<div class="input-field col s12">
<input id="image_alt_tag" type="text" name="image_alt_tag" class="validate" value="<?php echo $image_alt_tag ?>" required>
<label for="image_alt_tag">Image Alt Text</label>
</div>
</div>
<div class="row">
<div class="input-field col s12">
<textarea id="editor" name="description"><?php echo $description ?></textarea>
<!-- <label>about Descriptions:</label> -->
</div>
</div>
<div class="row">
<div class="input-field col s12">
<input type="submit" name="submit_rental" class="waves-effect waves-light btn-large" value="Submit">
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
<?php include('include/footer_admin.php'); ?>
<?php include('include/foot_admin.php'); ?>
</body>
</html>