<?php 
include('header.php'); 


$type = mysqli_escape_string($conn, $_REQUEST['type']);
$type_upper=$type;

			if($type=="event"){
				$page_back="event.php";
			}elseif($type=="media"){
				$page_back="media.php";
			}elseif($type=="team"){
				$page_back="team.php";
			}elseif($type=="services"){
				$page_back="services.php";
			}
			

if(isset($_REQUEST['check'])) { 
			
			
			$id = mysqli_escape_string($conn, $_REQUEST['id']);
			$type = mysqli_escape_string($conn, $_REQUEST['type']);
				
			include("upload_pix.php");
			
			$sql1 = "UPDATE post SET image_name = '$fn' WHERE id = '$id'";
			mysqli_query($conn, $sql1) or die(mysqli_error($conn));	
			
			
					
			$msg="<font color=\"green\"><b>Picture changed</b></font>
			<br/><br/>
			<a href=\"$page_back\">Go back</a>
			";
		
		
					
				
}


?>


      <!--main content start-->
      <section id="main-content">
        <section class="wrapper">
		 
			  
              <div class="row">
                  <div class="col-lg-12">
                      <section class="panel">
                          <header class="panel-heading">
                              <b>
                              <?php
                              print "<a href=\"$page_back\">$type</a>"
                              ?></b> (Change Picture)
						  </header>
                          <div class="panel-body">
                          
						<?php
						if(isset($msg)){
							print $msg;
						}
						?>                         
                          
                          
                        <div class="form">
                                  <form class="form-validate form-horizontal" method="POST" action="" enctype="multipart/form-data">
                                  
                                    <div class="form-group ">
                                          <label for="cname" class="control-label col-lg-2">Picture</label>
                                          <div class="col-lg-5">
                                             
                                              <input class="form-control" name="userfile" type="file" id="userfile" />
                                          Format: PNG, BMP, GIV, JPG or JPEG </div>
                                    </div>
                                 
                                    
                                      
									  
									 
                                      <div class="form-group">
                                          <div class="col-lg-offset-2 col-lg-10">
                                          
											  
											  <?php
											  print "<input name=\"type\" type=\"hidden\" value=\"$_REQUEST[type]\" />";
											  print "<input name=\"id\" type=\"hidden\" value=\" $_REQUEST[id]\" />";
											
												  print '
												  <button class="btn btn-primary" type="submit">Save</button>
													<input type="hidden" name="action" value="do_upload" />
													<input name="check" type="hidden" id="check" value="yes" />
												  ';
											 
											  ?>
                                          </div>
                                      </div>
                                      
                                     
                                  </form>
                              </div>

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

			  
			  
              <!-- page end-->
          </section>
      </section>
      <!--main content end-->
  </section>
  <!-- container section end -->

    <!-- javascripts -->
    <script src="../js/jquery.js"></script>
    <script src="../js/bootstrap.min.js"></script>
    <!-- nice scroll -->
    <script src="../js/jquery.scrollTo.min.js"></script>
    <script src="../js/jquery.nicescroll.js" type="text/javascript"></script>
    <!-- jquery validate js -->
    <script type="text/javascript" src="../js/jquery.validate.min.js"></script>

    <!-- custom form validation script for this page-->
    <script src="../js/form-validation-script.js"></script>
    <!--custome script for all page-->
    <script src="../js/scripts.js"></script>    


  </body>
</html>
