HOME


Mini Shell 1.0
DIR: /home/islapiiu/sites/thegarder/admin/
Upload File :
Current File : /home/islapiiu/sites/thegarder/admin/edit-member.php
<?php
include './header.php';
include("../class/resize-class.php");
$db = new DB();

$id = $_GET['i'];

if (isset($_POST['save-data'])) {

    if (!$_POST['name'] ) {
        ?>


        <div class="alert alert-danger alert-dismissible" role="alert">
            <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
            <strong>Error!</strong> Please enter the all data.
        </div>

        <?php
    } else {

        $emsg = "";
        $folderName = "../images/team/";
        $valid_image_check = array("image/gif", "image/jpeg", "image/jpg", "image/png", "image/bmp");

        $imgNames = array();

        for ($i = 0; $i < count($_FILES["image"]["name"]); $i++) {

            for ($i = 0; $i < count($_FILES["image"]["name"]); $i++) {

                if ($_FILES["image"]["name"][$i] <> "") {

                    $image_mime = strtolower(image_type_to_mime_type(exif_imagetype($_FILES["image"]["tmp_name"][$i])));
                    // if valid image type then upload
                    if (in_array($image_mime, $valid_image_check)) {

                        $ext = explode("/", strtolower($image_mime));
                        $ext = strtolower(end($ext));
                        $filename = rand(10000, 990000) . '_' . time() . '.' . $ext;
                        $filepath = $folderName . $filename;
                        array_push($imgNames, $filename);

                        if (!move_uploaded_file($_FILES["image"]["tmp_name"][$i], $filepath)) {
                            $emsg .= "Failed to upload <strong>" . $_FILES["image"]["name"][$i] . "</strong>. <br>";
                            $counter++;
                        } else {

                            $resizeObj = new resize($filepath);
                            $resizeObj->resizeImage(500, 500, 'crop');
                            $resizeObj->saveImage($filepath, 80);
                        }
                    } else {
                        $emsg .= "<strong>" . $_FILES["user_files"]["name"][$i] . "</strong> not a valid image. <br>";
                    }
                }
            }
        }

        if (isset($imgNames[0])) {
            $imgNames = $imgNames[0];
        } else {
            $imgNames = $_POST['oldPhoto'];
        }

        $sql = "UPDATE `team` SET "
                . "`name` = '" . mysql_real_escape_string($_POST['name']) . "',"
                . "`designation` = '" . mysql_real_escape_string($_POST['designation']) . "',"
                . "`photo` = '" . mysql_real_escape_string($imgNames) . "',"
                . "`details` = '" . mysql_real_escape_string($_POST['details']) . "' "
                . "WHERE `id` = '" . $_POST['id'] . "'";

        $db->readQuery($sql);

        echo '<input type="hidden" id="reload" value="1">';
        ?>


        <div class="alert alert-success alert-dismissible" role="alert">
            <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
            <strong>Success!</strong> Member Details "<?php echo $_POST['name']; ?>"   was updated successfully.
        </div>

        <?php
    }
}


$member = getMemberById($id);


?> 
<link rel="stylesheet" href="css/lightbox.css">

<div class="panel panel-default">
    <div class="panel-heading">
        <h3 class="panel-title">Edit Member : <?php echo $member["name"]; ?> </h3>
    </div>
    <div class="panel-body">

        <div class="row">
            <div class="col-sm-9">
                <form action="" method="POST" enctype="multipart/form-data" class="form-horizontal" id="main-form">

                    <div class="form-group">
                        <label class="col-sm-3 control-label">Picture: </label>
                        <div class="col-sm-9"> 
                            <img class="example-image img-responsive" src="../images/team/<?php echo $member["photo"]; ?>" alt="" style="height: 200px;"/>  
                        </div>
                    </div>

                    <div class="form-group">
                        <label for="name" class="col-sm-3 control-label">Name: </label>
                        <div class="col-sm-9">
                            <input type="text" value="<?php echo $member["name"]; ?>" name="name"  class="form-control"  id="name"  required="TRUE"> 
                            <input type="hidden" value="<?php echo $member["id"]; ?>" name="id" required="TRUE"> 
                        </div>
                    </div>

                    <div class="form-group">
                        <label for="image" class="col-sm-3 control-label">Photo: </label>
                        <div class="col-sm-9">
                            <input type="file" name="image[]"  class="form-control"  id="image" /> 
                            <input type="hidden" value="<?php echo $member["photo"]; ?>" name="oldPhoto" required="TRUE">
                        </div>
                    </div>


                    <div class="form-group">
                        <label for="designation" class="col-sm-3 control-label">Designation: </label>
                        <div class="col-sm-9">
                            <input type="text" value="<?php echo $member["designation"]; ?>" name="designation"  class="form-control"  id="designation"  required="TRUE">  
                        </div>
                    </div>


                    <div class="form-group">
                        <label for="details" class="col-sm-3 control-label">Description: </label>
                        <div class="col-sm-9">
                            <input type="text" value="<?php echo $member["details"]; ?>" name="details"  class="form-control"  id="details"  required="TRUE">  
                        </div>
                    </div>


                    <div class="form-group">
                        <div class="col-sm-offset-3 col-sm-9"> 
                            <input type="submit" class="btn btn-default" id="btn-submit" value="Save" name="save-data">
                        </div>
                    </div>
                </form> 
            </div>
        </div>
    </div>

</div>
<script src="js/lightbox-plus-jquery.min.js"></script>
<?php
include './footer.php';
?>