PK

ADDRLIN : /home/bw2hgtn172qm/www/jeffharrismusic.com/admin/
FLL :
Current File : /home/bw2hgtn172qm/www/jeffharrismusic.com/admin/add_news.php

<?php 
include("header.php");
@extract($_POST);
  $cur_date_time=date("Y-m-d H:i:s", time());
//addslashes
$news_title=addslashes('News_title');
$news_description=addslashes('News_description');
$news_image=addslashes('news_image');
$news_current_time=addslashes('news_current_time');
$news_status=addslashes('news_status'); 
if(isset($_POST['submit']))
{ 	
	 $errors=array();
	$current_times = str_replace(':', '_', $current_time);
	$file_name=$current_date.'_'.$current_times.'_'.$_FILES["uploadedimage"]["name"];
	
	$file_size=$_FILES["uploadedimage"]["size"];
	$temp_name=$_FILES["uploadedimage"]["tmp_name"];
	$file_type=$_FILES["uploadedimage"]["type"];
	$target_path="uploads/news_img/";
	$file_ext=explode('.',$_FILES["uploadedimage"]["name"]);
	$expensions=array("jpeg","jpg","png");
	
	if(in_array($file_ext,$expensions)=== false)
	{
		$errors[]="Choose PNG or JPEG Files";
	}
	
	if($file_size > 5242880)
	{
		$errors[]='File Size should be less than 5MB';
	}
	move_uploaded_file($temp_name,$target_path.$file_name);  
	if($_FILES["uploadedimage"]["name"]!='')
	{
	//$add_query= "insert into jeff_news(News_title,news_description,news_image,status)VALUES('$news_title','$news_description','$file_name','1')";
	 $add_query="INSERT INTO `jeff_news` (`news_title`, `news_description`, `news_image`, `status`) VALUES ('$News_title', '$News_description', '$file_name', '1')"; 
	
	$rs=mysqli_query($conn,$add_query);
	}
	else
	{
	//$add_query= "insert into jeff_news(News_title,news_description,status)VALUES('$news_title','$news_description','1')";
	 $add_query="INSERT INTO `jeff_news` (`news_title`, `news_description`, `status`) VALUES ('$News_title', '$News_description','1')"; 
	

	 $rs=mysqli_query($conn,$add_query);
	
	}
	if($rs)
	{
		echo "<script>window.location='news_management.php';</script>";
	}
	else
	{
			  echo "<script>window.location='news_management.php?msg=success';</script>";
	}
}

?>

 <script>
 
 function validate()
 {
	 
	 if(document.news_management.News_title.value=="")
	{
		document.getElementById("error_message").innerHTML='<p style="color:red;padding-top:5px;">Enter Your News</p>';
		news_management.News_title.focus();
		return(false);	
	}
	else
	{
		document.getElementById("error_message").innerHTML='<span><font color="#FF0000"></font></span>';
	}
	 
	if(document.news_management.News_description.value=="")
	{
		document.getElementById("error_message").innerHTML='<p style="color:red;padding-top:5px;">Enter your description</p>';
		news_management.News_description.focus();
		return(false);	
	}
	else
	{
		document.getElementById("error_message").innerHTML='<span><font color="#FF0000"></font></span>';
	}
	
	if(document.news_management.news_image.value=="")
	{
		document.getElementById("error_message").innerHTML='<p style="color:red;padding-top:5px;">Upload your News Image</p>';
		news_management.news_image.focus();
		return(false);	
	}
	else
	{
		document.getElementById("error_message").innerHTML='<span><font color="#FF0000"></font></span>';
	}
 }

 </script>

<style>
#header_hover:hover{
	background-color:#000 ! important;
}
</style>
<div id="wrapper">
	<?php include('sidebar.php');?>
        <div id="page-wrapper" class="gray-bg">
         <?php include('afterlog_top.php'); ?>
			<!--------- Title ------------>
            <div class="row wrapper border-bottom white-bg page-heading">
                <div class="col-lg-10">
                    <h2>Add News</h2>
                    <ol class="breadcrumb">
                        <li>
                            <a href="dashboard.php">Home</a>
                        </li>
                        
                        <li class="active">
                            <strong>Add News</strong>
                        </li>
                    </ol>
                </div>
                <div class="col-lg-2">

                </div>
            </div>
			<!--------- End Title ------------>
			<div class="wrapper wrapper-content">
				<div class="row animated fadeInRight">
					<div class="col-md-12">
						<div class="ibox float-e-margins">
							<div class="ibox-title">
								<a href="" class="btn btn-danger btn-xs" id="header_hover" ><h5 >Add</h5></a>
								<a href="news_management.php" class="btn btn-primary btn-xs" ><h5 >News Management</h5></a>
								<div class="pull-right tooltip-demo ibox-tools">
									<a class="collapse-link">
										<i class="fa fa-chevron-up"></i>
									</a>
									<a class="close-link">
										<i class="fa fa-times"></i>
									</a>
								</div>
							</div>
						<!---------------- Form ---------------->
							<div class="ibox-content">
								<div class="row">
									<div class="col-lg-1"></div>
									<div class="col-lg-10">
									<span id="error_message" style="color:#FF0000;font-size:14px;text-align: center;font-weight:600;"></span>
										<form class="form-horizontal" enctype="multipart/form-data" id="news_management" name="news_management" method="post" action="" onsubmit="return validate();">
										
											<div class="form-group">
												<label style="text-align:left;" class="col-lg-4 control-label">News_Title<span style="color:#FF0000;">*</span></label>
												<div class="col-lg-8"> 
													<input style="color:#777;" name="News_title" id="news_title" placeholder="News Title" type="text" class="form-control"  value=""/>
												</div>
											</div>
											<div class="form-group">
												<label style="text-align:left;" class="col-lg-4 control-label">News_Description<span style="color:#FF0000;">*</span></label>
												<div class="col-lg-8"> 
													<textarea rows="4" cols="77" name="News_description" id="news_description" placeholder="News Description" type="text"></textarea>
												</div>
											</div>
											<div class="form-group">
												<label style="text-align:left;" class="col-lg-4 control-label">News Image<span style="color:#FF0000;">*</span></label>
												<div class="fileinput fileinput-new input-group" data-provides="fileinput">
												<div class="form-control" data-trigger="fileinput">
													<i class="glyphicon glyphicon-file fileinput-exists"></i> 
												</div>
													<span class="input-group-addon btn btn-default btn-file">
													<span class="fileinput new">Select file</span>
													<input type="file" id="uploadedimage" name="uploadedimage"  placeholder="Enter upload news image Here...">
													<span class="fileinput-exists">Change</span>
													</span>
													<a href="#" class="input-group-addon btn btn-default fileinput-exists" data-dismiss="fileinput">Remove</a>
												</div>		
											</div>
										<div class="form-group">
												<div class="col-lg-offset-4 col-lg-12">
													<input class="btn btn-danger" type="button"  value="Back" onclick="window.history.back();">
													<input class="btn btn-success" type="submit" name="submit" value="submit">
												</div>
											</div>
										</form>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
		    </div>
			<?php
include("footer.php")
?>
		</div>
	</div>
</body>

<script>
 //================ Date Picker==============
        $(document).ready(function(){

            $('#data_1 .input-group.date').datepicker({
                todayBtn: "linked",
                keyboardNavigation: false,
                forceParse: false,
                calendarWeeks: true,
                autoclose: true,
				format: "yyyy-mm-dd"
            });
          
            $(".touchspin3").TouchSpin({
                verticalbuttons: true,
                buttondown_class: 'btn btn-white',
                buttonup_class: 'btn btn-white'
            });

            $('.dual_select').bootstrapDualListbox({
                selectorMinimalHeight: 160
            });


        });
</script>


PK 99