PK

ADDRLIN : /home/anibklip/msbhogalnsons.com/cms/
FLL :
Current File : /home/anibklip/msbhogalnsons.com/cms/add_gallery_image.php

<center>
<?php
if($_POST[submt_btn] ==	1){	
	//echo "<pre>";print_r($_FILES);echo "</pre>";
	$uploads_dir = '../site_data/gallery_images/';

	$a=($_GET[image_id]?5:1); 
	for(;$a<=5;$a++){
		if($_GET[image_id]!=""){
			$query="update gallery_images set	
				gallery_id='$_POST[gallery_id]',
				image_details='".mysql_escape_string($_POST["image_details"])."'
				where image_id = '$_GET[image_id]'
			";
			//echo "<pre>$query</pre>";
			mysqli_query($conn,$query)	or die(mysqli_error($conn));
			$image_id=$_GET[image_id];
			$msg="Record Updated Successfully.";
		}else{
			$query="insert into	gallery_images set 
				gallery_id='$_POST[gallery_id]', 
				image_details='".mysql_escape_string($_POST["image_details"])."'
			";
			mysqli_query($conn,$query)	or die(mysqli_error($conn));
			$image_id=mysql_insert_id();
			$msg="Record Added Successfully.";
		}

		if($_FILES["img".$a]["error"] == UPLOAD_ERR_OK) {
			$tmp_name =	$_FILES["img".$a]["tmp_name"];
			$ext=substr($_FILES["img".$a]["name"],-3);
			$fname = $image_id."_img.".$ext;

			$obj_img = new thumbnail_images();
			$obj_img->PathImgOld = $_FILES['img'.$a]['tmp_name'];
			$obj_img->PathImgNew = $uploads_dir."th_".$fname;
			$obj_img->NewWidth = 250;
			$obj_img->NewHeight	= 300;
			$obj_img->create_thumbnail_images();
			move_uploaded_file($tmp_name, "$uploads_dir$fname");
			
			$query="update gallery_images set image_file='$fname' where image_id='$image_id'";
			mysqli_query($conn,$query)	or die(mysqli_error($conn));
		}
	}
}

//////////////////////	fetch data for edit	starts ////////////////////////
if($_GET[image_id]){
	$query = "select * from	gallery_images where image_id =	'$_GET[image_id]'";
	$query = mysqli_query($conn,$query) or die(mysqli_error($conn));
	if($editrow=mysqli_fetch_array($query)){}
}
//////////////////////	fetch data for edit	ends ////////////////////////
?>

</center>

 
<!-- BEGIN PAGE LEVEL STYLES -->
<link rel="stylesheet" type="text/css" href="assets/global/plugins/select2/select2.css"/>
<link rel="stylesheet" type="text/css" href="assets/global/plugins/bootstrap-wysihtml5/bootstrap-wysihtml5.css"/>
<link rel="stylesheet" type="text/css" href="assets/global/plugins/bootstrap-markdown/css/bootstrap-markdown.min.css">
<link rel="stylesheet" type="text/css" href="assets/global/plugins/bootstrap-datepicker/css/bootstrap-datepicker3.min.css"/>
<!-- END PAGE LEVEL SCRIPTS -->

<!-- BEGIN CONTAINER -->
<!-- BEGIN CONTENT -->
<div class="page-content">
    <!-- BEGIN PAGE HEADER-->
    <h3 class="page-title"><?php echo ($_GET[image_id]?"Update":"Add")?> Gallery Image<small></small></h3>
    <div class="page-bar">
        <ul class="page-breadcrumb">
            <li>
				<i class="fa fa-home"></i>
				<a href="main.php">Home</a>
				<i class="fa fa-angle-right"></i>
            </li>
        </ul>
        <!--<div class="page-toolbar">
            <div class="btn-group pull-right">
                <button type="button" class="btn btn-fit-height grey-salt dropdown-toggle" data-toggle="dropdown" data-hover="dropdown" data-delay="1000" data-close-others="true">
                Actions <i class="fa fa-angle-down"></i>
                </button>
                <ul class="dropdown-menu pull-right" role="menu">
                    <li>
                        <a href="#">Action</a>
                    </li>
                    <li>
                        <a href="#">Another action</a>
                    </li>
                    <li>
                        <a href="#">Something else here</a>
                    </li>
                    <li class="divider">
                    </li>
                    <li>
                        <a href="#">Separated link</a>
                    </li>
                </ul>
            </div>
        </div>-->
    </div>
    <!-- END PAGE HEADER-->
    <!-- BEGIN PAGE CONTENT-->
    
    <div class="row">
        <div class="col-md-12">
            <!-- BEGIN VALIDATION STATES--> 
            <div class="portlet box purple">
                <div class="portlet-title">
                    <div class="caption">
                        <i class="fa fa-gift"></i><?php echo ($_GET[image_id]?"Update":"Add")?> Gallery Image
                    </div>
                </div>
                <div class="portlet-body form">
                    <!-- BEGIN FORM-->
                    <form action="" method="post" id="form_sample_1" enctype="multipart/form-data" class="form-horizontal">
                        <div class="form-body">
							<?php if($msg){?><div class="alert alert-success display-show"><button class="close" data-close="alert"></button><?=$msg?></div><?php }?>

							<!-- <?php if($errmsg){?><div class="alert alert-error"><strong>Error!</strong>&nbsp; <?php echo $errmsg?></div><?php }?> -->

							<div class="alert alert-danger display-hide">
                                <button class="close" data-close="alert"></button>
                                You have some form errors. Please check below.
                            </div>
							
							<div class="form-group">
                                <label class="control-label col-md-3">Gallery<span class="required">* </span></label>
                                <div class="col-md-4">
                                    <select name="gallery_id" class="form-control" required>
										<option	value="">Select	Gallery</option>
										<?php
										$q="select * from gallery order by titl ";
										$q=mysqli_query($conn,$q) or die(mysqli_error($conn));
										while($r=mysqli_fetch_array($q)){
											if($r[gallery_id]==$editrow[gallery_id]){
												$sel="selected='selected'";
											}else{
												$sel="";
											}
											?>
											<option	value="<?php echo $r[gallery_id]?>" <?php	echo $sel?>><?php echo $r[titl]?></option>
											<?php
										}
										?>
									  </select>
                                </div>
                            </div>
							<div class="form-group">
								<label class="control-label col-md-3">Caption<span class="required">* </span></label>
								<div class="col-md-4">
									<input type="text" class="form-control" name="image_details" id="image_details" value="<?php echo $editrow[image_details]?>" />
								</div>
							</div>

							<?php
							$a=($_GET[image_id]?5:1); 
							for(;$a<=5;$a++){
								?>
								<div class="form-group">
									<label class="control-label col-md-3">Image File <?php echo $a ?><span class="required">* </span></label>
									<div class="col-md-4">
										<input type="file" name="img<?php echo $a ?>" accept="image/*" />
										<?php if($editrow[image_file]){?><img src="../site_data/gallery_images/th_<?php echo $editrow[image_file];?>" width="80" /><?php } ?>
									</div>
								</div>
								<?php
							}
							?>
						</div>
                        <div class="form-actions">
                            <div class="row">
                                <div class="col-md-offset-3 col-md-9">
                                    <button type="submit" name="submt_btn" value="1" class="btn green"><?php echo ($_GET[image_id]?"Update":"Submit")?></button>
                                    <button type="reset" class="btn default">Cancel</button>
                                </div>
                            </div>
                        </div>
                    </form>
                    <!-- END FORM-->
                </div>
            </div>
            <!-- END VALIDATION STATES-->
        </div>
    </div>
    <!-- END PAGE CONTENT-->
</div>
<!-- END CONTENT -->
<!-- END CONTAINER -->


PK 99