src/Controller/UserController.php
public function CreateAction()
  {
    // Checks if the form has been completed
    if (!empty($_POST))
    {
      // Search the user in the DB
      $user = ModelFactory::get('User')->read($_POST['email'], 'email');

      // Checks if the user exists already
      if (empty($user) == false)
      {
        // Creates a fail message to inform that an existing account uses this email address
        htmlspecialchars(Session::createAlert('There is already a user account with this email address'));
      }
      // Uploads the image & gets back the file name
      $data['image'] = $this->upload('img/user');

      // Hashes the user password
      $data['pass'] = password_hash($_POST['pass'], PASSWORD_DEFAULT);

      // Creates the $data array to store the new user
      $data['first_name']   = $_POST['first_name'];
      $data['last_name']    = $_POST['last_name'];
      $data['zipcode']      = $_POST['zipcode'];
      $data['country']      = $_POST['country'];
      $data['email']        = $_POST['email'];
      $data['created_date'] = $_POST['date'];
      $data['updated_date'] = $_POST['date'];

      // Creates a new user
      ModelFactory::get('User')->create($data);

      // Creates a valid message to confirm the creation of a new user
      htmlspecialchars(Session::createAlert('New user created successfully !', 'valid'));

      // Redirects to the view home
      $this->redirect('home');
    }
    else {
      // Returns the rendering of the view createUser with the empty fields
      return $this->render('user/createUser.twig');
    }
  }
public function CreateAction()
  {
    // Checks if the form has been completed
    if (!empty($_POST))
    {
      // Search the user in the DB
      $user = ModelFactory::get('User')->read($_POST['email'], 'email');

      // Checks if the user exists already
      if (empty($user) == false)
      {
        // Creates a fail message to inform that an existing account uses this email address
        htmlspecialchars(Session::createAlert('There is already a user account with this email address'));
      }
      // Uploads the image & gets back the file name
      $data['image'] = $this->upload('img/user');

      // Hashes the user password
      $data['pass'] = password_hash($_POST['pass'], PASSWORD_DEFAULT);

      // Creates the $data array to store the new user
      $data['first_name']   = $_POST['first_name'];
      $data['last_name']    = $_POST['last_name'];
      $data['zipcode']      = $_POST['zipcode'];
      $data['country']      = $_POST['country'];
      $data['email']        = $_POST['email'];
      $data['created_date'] = $_POST['date'];
      $data['updated_date'] = $_POST['date'];

      // Creates a new user
      ModelFactory::get('User')->create($data);

      // Creates a valid message to confirm the creation of a new user
      htmlspecialchars(Session::createAlert('New user created successfully !', 'valid'));

      // Redirects to the view home
      $this->redirect('home');
    }
    else {
      // Returns the rendering of the view createUser with the empty fields
      return $this->render('user/createUser.twig');
    }
  }
****************\
Creates a new user
@return mixed => the rendering of the view createUser