<file_sep>
<?php include 'app/views/inc/header.php';?>;




<h1>WELCOME TO MY BLOG</h1>




<?php include 'app/views/inc/footer.php';?><file_sep><?php

/**
 * Test Controller
 */
class Test 
{
	
	function __construct()
	{
		echo "I'm Test from Test Controller";
	}
}<file_sep><?php
/**
 * Category Controller
 */

 Class Category extends Dcontroller{

    function __construct()
    {
        parent::__construct();
    }




    public function categoryList(){

        $data = array();
        $table = 'category';
       $catModel = $this->load->model("CatModel");
       $data['cat'] = $catModel -> catList($table);
       $this->load->view("category",$data);
       
      }
  
  
  
      public function catById(){
        $data = array();
        $table = 'category';
        $id = 40;
       $catModel = $this->load->model("CatModel");
       $data['catbyid'] = $catModel -> catByid($table,$id);
       $this->load->view("catbyid",$data);  
      }
  
  
      public function addCategory(){
  
        $this->load->view("addcategory");
  
  
      }
  
  
      public function InsertCategory(){
  
        $table = 'category';
  
        $name = $_POST['name'];
        $title = $_POST['title'];
  
        $data = array(
  
          'name' => $name,
          'title' => $title
        );
  
        $catModel = $this->load->model("CatModel");
        $result = $catModel -> insertCat($table, $data);
  
        $msg = array();
  
        if ($result ==1) {
          $msg['msg'] = "Category added successfully...!";
        } else {
          $msg['msg'] = "Category not added";
        }
        $this->load->view("addcategory",$msg);
        
      }


      public function updateCat(){

        $table = 'category';
        $cond = "id = 41";

  
        $data = array(
  
          'name' => 'Cool',
          'title' => 'Super'
        );
        $catModel = $this->load->model("CatModel");
        $catModel -> catUpdate($table, $data, $cond);

      }


      public function deleteCatById(){

        $table ='category';
        $cond = "id = 48";
        $catModel = $this->load->model("CatModel");
        $catModel -> delCatById($table,$cond);
    }


  
  



 }<file_sep><?php include 'app/views/inc/header.php';?>



<div class = "content">

<h1>CATEGORY BY ID</h1><HR/>

<?php

  foreach ($catbyid as $key => $value) {
    echo $value['title']."<br/>"; }

?>

</div>



<?php include 'app/views/inc/footer.php';?>



<file_sep><?php

/**
 * Main Model
 */
class DModel 
{
	

	protected $db = array();
	public  function __construct()
	{

        $dns = 'mysql:dbname=oc_blog;host=localhost';
        $user = 'gilles';
        $pass = '<PASSWORD>';


		$this -> db = new Database($dns,$user,$pass);
	}
}<file_sep>
<?php include 'app/views/inc/header.php';?>




<div class = "content">

<h1>CATEGORY LIST</h1><HR/>

<?php

  foreach ($cat as $key => $value) {
    echo $value['title']."<br/>"; }

?>

</div>




<?php include 'app/views/inc/footer.php';?><file_sep><?php
/**
 * Index Controller
 */

class Index extends Dcontroller {

   

  public  function __construct(){
      
    parent::__construct();
        
    }


    public function home(){

     $this->load->view("home");

    }



    public function category(){

      $data = array();
      $table = 'category';
     $catModel = $this->load->model("CatModel");
     $data['cat'] = $catModel -> catList($table);
     $this->load->view("category",$data);
     
    }



    public function catById(){
      $data = array();
      $table = 'category';
      $id = 10;
     $catModel = $this->load->model("CatModel");
     $data['catbyid'] = $catModel -> catByid($table,$id);
     $this->load->view("catbyid",$data);  
    }


    public function addCategory(){

      $this->load->view("addcategory");


    }


    public function InsertCategory(){

      $table = 'category';

      $name = $_POST['name'];
      $title = $_POST['title'];

      $data = array(

        'name' => $name,
        'title' => $title
      );

      $catModel = $this->load->model("CatModel");
      $result = $catModel -> insertCat($table, $data);

      $msg = array();

      if ($result ==1) {
        $msg['msg'] = "Category added successfully...!";
      } else {
        $msg['msg'] = "Category not added";
      }
      $this->load->view("addcategory",$msg);
      
    }



   


      
       
}
<file_sep> <?php

/**
 * Category Model
 */


 class CatModel extends DModel{

    public function __construct()
    {
        parent::__construct();
    }


    public function catList($table){
        $sql = "select * from $table";
        return $this -> db -> select( $sql);
        
    }

    public function catById($table,$id){

        $sql = "select * from $table where id=:id";
        $data = array(":id" => $id);
        return $this -> db -> select($sql,$data);
        }


    public function  insertCat($table, $data){

       return  $this -> db -> insert($table, $data);

    }

        public function catUpdate($table, $data, $cond){

            return  $this -> db -> update ($table, $data, $cond);
        }


        public function delCatById($table,$cond){

            return  $this -> db -> delete ($table,$cond);

        }
 }<file_sep><?php
session_start();
if ( isset( $_SESSION['id'] ) ) {
  header( 'Location: account_user.php' );
}

if ( !empty( $_POST ) ) {
  extract( $_POST );
  $error = [];

  require_once '../Controllers/functions.php';

  if ( empty( $email ) ) {
    $error['email'] = 'Email address missing';
  }
  elseif ( !filter_var( $email, FILTER_VALIDATE_EMAIL ) ) {
    $error['email'] = 'Invalid email address';
  }
  elseif ( !mail_free() ) {
    $error['email'] = 'email address already taken';
  }

  if ( empty( $password ) ) {
    $erreur['password'] = '<PASSWORD>';
  }
  elseif ( strlen( $password ) < 8 ) {
    $error['password'] = 'Password <PASSWORD>';
  }

  if ( empty( $passwordconf ) ) {
    $error['passwordconf'] = 'Password confirmation missing';
  }
  elseif ( $passwordconf != $password ) {
    $error['passwordconf'] = 'Password confirmation';
  }

  if ( !$error ) {
    bdd_insert( 'INSERT INTO user (email, password) VALUES (:email, :password)', [
      'email' => $email,
      'password' => password_hash( $password, <PASSWORD> )
    ] );

    unset( $email );

    $validation = 'SUCCESS  !';
  }
}
?>g
<!DOCTYPE html>
<html lang="fr">
  <head>
    <meta charset="utf-8">
    <title>SIGN UP</title>
    <link rel="stylesheet" href="css/bootstrap.min.css">
    <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Nunito:400,700,300">
    <link rel="stylesheet" href="css/style.css">
  </head>
  <body>
    <?php include 'inc/header.php' ?>
    <div class="container">
      <h1 class="text-xs-center">SIGN UP</h1>
      <div class="row">
        <div class="col-xl-4 col-xl-offset-4 col-md-6 col-md-offset-3">
          <?php if ( isset( $error['email'] ) ) : ?>
            <div class="alert alert-danger"><?= $error['email'] ?></div>
          <?php endif; ?>
          <?php if ( isset( $error['password'] ) ) : ?>
            <div class="alert alert-danger"><?= $error['password'] ?></div>
          <?php endif; ?>
          <?php if ( isset( $error['passwordconf'] ) ) : ?>
            <div class="alert alert-danger"><?= $error['passwordconf'] ?></div>
          <?php endif; ?>
          <?php if ( isset( $validation ) ) : ?>
            <div class="alert alert-success"><?= $validation ?></div>
          <?php endif; ?>
          <form action="signup.php" method="post" class="p-y-3 p-x-2" novalidate>
            <input type="email" name="email" class="form-control" placeholder="Email address" value="<?php if ( isset( $email ) ) echo $email ?>">
            <input type="<PASSWORD>" name="password" class="form-control" placeholder="<PASSWORD>">
            <input type="<PASSWORD>" name="<PASSWORD>" class="form-control" placeholder="<PASSWORD>">
            <input type="submit" class="btn btn-success" value="Sign up">
          </form>
        </div>
      </div>
    </div>
  </body>
</html>c<file_sep><?php

/**
 * Gilles Controller
 */
class Gilles extends Dcontroller
{
	
	public function __construct()
	{
		//echo parent::__construct();
	}

	public function Patrick($p){

		echo "Patrick from a method $p";
	}
}<file_sep><?php


/**
 * Main Controller
 */
class Dcontroller
{
	protected $load  = array();


	public function __construct()
	{
		$this -> load = new Load();
		
	}
}<file_sep>
<?php include 'app/views/inc/header.php';?>;








<!-- Contact Section -->
<section id="contact">
      <div class="container">
        <h2 class="text-center text-uppercase text-secondary mb-0">add categories</h2>
        <hr class="star-dark mb-5">
        
        
        
        
        
        
        <div class="row">
          <div class="col-lg-8 mx-auto">
            <!-- To configure the contact form email address, go to mail/contact_me.php and update the email address in the PHP file on line 19. -->
            <!-- The form should work on most web servers, but if the form is not working you may need to configure your web server differently. -->
            <form  action="http://localhost/OC_BLOG/index.php?url=Category/InsertCategory" method="post">
              
                <center>
                    <?php 
                        if(isset($msg)){
                        echo "<span style = 'color:green; font-weight:bold'>".$msg."</span>";
                        }
            
                    ?>
                </center>
              <div class="control-group">
                <div class="form-group floating-label-form-group controls mb-0 pb-2">
                  <label>Name</label>
                  <input class="form-control" name="name" type="text" placeholder="Name" required="1"  data-validation-required-message="Please enter your name.">
                  <p class="help-block text-danger"></p>
                </div>
              </div>  

              <div class="control-group">
                <div class="form-group floating-label-form-group controls mb-0 pb-2">
                  <label>Title</label>
                  <input class="form-control " name="title" id="title" type="text" required="1" placeholder="Title"  data-validation-required-message="Please enter the title." >
                  <p class="help-block text-danger"></p>
                </div>
              </div>

              

              <br>
              <div id="success"></div>
              <div class="form-group">
                <button type="submit" class="btn btn-primary btn-xl" id="AddCategoryButton">Save</button>
              </div>
            </form>
          </div>
        </div>
      </div>
    </section>






<?php include 'app/views/inc/footer.php';?><file_sep># OC_BLOG
OC_BLOG a web application project with the PHP programming language that will present my blog.
