<?php
session_start();
error_reporting(0);
include'dbconnection.php';
//Checking session is valid or not
if (strlen($_SESSION['id']==0)) {
  header('location:logout.php');
  } else{

//Code for Add Update
if(isset($_POST['submit']))
{
	$name=$_POST['name'];
	$content=$_POST['content'];

	$img = $_FILES["upload"]["name"];
    $tempname = $_FILES["upload"]["tmp_name"];
    $folder="../images/".$img;


	

if (move_uploaded_file($tempname, $folder)) {
    $query=mysqli_query($con,"insert into causes(causes_img,causes_content,causes_name) values('$img','$content','$name')");
    echo "<script>alert('Register successfully');</script>";
}
else {
    "<script>alert('Failed to add new cause');</script>";
}
}
  
?>




<?php







?>

</script>
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="Dashboard">
    <meta name="keyword" content="Dashboard, Bootstrap, Admin, Template, Theme, Responsive, Fluid, Retina">
    <link rel="icon" type="image/png"  href="assets/images/favicon.png">
    <title>Admin | Add Home</title>
    <link href="assets/css/bootstrap.css" rel="stylesheet">
    <link href="assets/font-awesome/css/font-awesome.css" rel="stylesheet" />
    <link href="assets/css/style.css" rel="stylesheet">
    <link href="assets/css/style-responsive.css" rel="stylesheet">
    <link href="plugins/summernote/summernote.css" rel="stylesheet" />
              
              <!-- Select2 -->
              <link href="plugins/select2/css/select2.min.css" rel="stylesheet" type="text/css" />
              
              <!-- Jquery filer css -->
              <link href="plugins/jquery.filer/css/jquery.filer.css" rel="stylesheet" />
              <link href="plugins/jquery.filer/css/themes/jquery.filer-dragdropbox-theme.css" rel="stylesheet" />
              
              <!-- App css -->
              <link href="assets/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
              <link href="assets/css/core.css" rel="stylesheet" type="text/css" />
              <link href="assets/css/components.css" rel="stylesheet" type="text/css" />
              <link href="assets/css/icons.css" rel="stylesheet" type="text/css" />
              <link href="assets/css/pages.css" rel="stylesheet" type="text/css" />
              <link href="assets/css/menu.css" rel="stylesheet" type="text/css" />
              <link href="assets/css/responsive.css" rel="stylesheet" type="text/css" />
              <link rel="stylesheet" href="plugins/switchery/switchery.min.css">
              <script src="assets/js/modernizr.min.js"></script>
              
  </head>

  <body>

  <section id="container" >
      <header class="header black-bg">
              <div class="sidebar-toggle-box">
                  <div class="fa fa-bars tooltips" data-placement="right" data-original-title="Toggle Navigation"></div>
              </div>
            <a href="#" class="logo"><b>Admin Dashboard</b></a>
            <div class="nav notify-row" id="top_menu">
               
                         
                   
                </ul>
            </div>
            <div class="top-menu">
            	<ul class="nav pull-right top-menu">
                    <li><a class="logout" href="logout.php">Logout</a></li>
            	</ul>
            </div>
        </header>
        <?php include 'sidebar.php'?>
      <section id="main-content">
          <section class="wrapper">
          	<h3><i class="fa fa-angle-right"></i> Add Event</h3>
				<div class="row">
				
                  
	                  
                  <div class="col-md-8">
                      <div class="content-panel">
                           <form class="form-horizontal style-form" name="" method="post" action="" enctype="multipart/form-data">
                           <p style="color:#F00"><?php echo $_SESSION['msg'];?><?php echo $_SESSION['msg']="";?></p>
                         
                          
                              <div class="form-group">
                              <label class="col-sm-2 col-sm-2 control-label" style="padding-left:40px;">Causes Cover Image</label>
                              <div class="col-sm-10">
                                  <input type="file" class="form-control" name="upload" value="" >
                              </div>
                          </div>
                          <div class="form-group">
                              <label class="col-sm-2 col-sm-2 control-label" style="padding-left:40px;">Causes Name</label>
                              <div class="col-sm-10">
                                  <input type="text" class="form-control" name="name" value="" >
                              </div>
                          </div>
                          
                              <div class="form-group">
                              <label class="col-sm-2 col-sm-2 control-label" style="padding-left:40px;">Causes Content</label>
                              <div class="col-sm-10">
                                 <textarea id="output" class= "summernote" name="desc" required></textarea>
                              </div>
                          </div>
                          
                          <div style="margin-left:100px;">
                          <input type="submit" name="submit" value="submit" class="btn btn-theme"></div>
                          </form>
                      </div>
                  </div>
              </div>
		</section>
      </section></section>

      
      <script>
            var resizefunc = [];
        </script>
        

          <!-- jQuery  -->
          <script src="assets/js/jquery.min.js"></script>
        <script src="assets/js/bootstrap.min.js"></script>
        <script src="assets/js/detect.js"></script>
        <script src="assets/js/fastclick.js"></script>
        <script src="assets/js/jquery.blockUI.js"></script>
        <script src="assets/js/waves.js"></script>
        <script src="assets/js/jquery.slimscroll.js"></script>
        <script src="assets/js/jquery.scrollTo.min.js"></script>
        <script src="plugins/switchery/switchery.min.js"></script>

        <!--Summernote js-->
        <script src="plugins/summernote/summernote.min.js"></script>
      
        <!-- Select 2 -->
        <script src="plugins/select2/js/select2.min.js"></script>
        <!-- Jquery filer js -->
        <script src="plugins/jquery.filer/js/jquery.filer.min.js"></script>

        <!-- page specific js -->
        <script src="assets/pages/jquery.blog-add.init.js"></script>

        <!-- App js -->
        <script src="assets/js/jquery.core.js"></script>
        <script src="assets/js/jquery.app.js"></script>

        <script>

            jQuery(document).ready(function(){

                $('.summernote').summernote({
                    height: 240,                 // set editor height
                    minHeight: null,             // set minimum height of editor
                    maxHeight: null,             // set maximum height of editor
                    focus: false                 // set focus to editable area after initializing summernote
                });
                // Select2
                $(".select2").select2();

                $(".select2-limiting").select2({
                    maximumSelectionLength: 2
                });
            });
        </script>
  <script src="plugins/switchery/switchery.min.js"></script>

        <!--Summernote js-->
        <script src="plugins/summernote/summernote.min.js"></script>
    <script src="assets/js/jquery.js"></script>
    <script src="assets/js/bootstrap.min.js"></script>
    <script class="include" type="text/javascript" src="assets/js/jquery.dcjqaccordion.2.7.js"></script>
    <script src="assets/js/jquery.scrollTo.min.js"></script>
    <script src="assets/js/jquery.nicescroll.js" type="text/javascript"></script>
    <script src="assets/js/common-scripts.js"></script>
  <script>
      $(function(){
          $('select.styled').customSelect();
      });

  </script>

  </body>
</html>
<?php } ?>
