Welcome Guest, Not a member yet? Register   Sign In
[SOLVED] Callback Error Message Not Showing Where Should Be
#3

[eluser]riwakawd[/eluser]
I have got it all working with custom library called request. Which also built in xss_clean. All works perfect now.

Code:
<?php

class Step_3 extends CI_Controller {
private $error = array();

public function index() {

  $this->lang->load('install', 'english');

  $data['title'] = 'Configuration';

  $data['base'] = base_url();

  if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {

   $this->load->model('model_install');

   $this->model_install->database($this->request->post);
  
   redirect(site_url('/'));

  }

   $data['entry_username'] = "Username";
   $data['entry_password'] = "Password";
   $data['entry_email'] = "Email";

   $data['button_continue'] = "Continue";
   $data['button_back'] = "Back";

   if (isset($this->error['warning'])) {
    $data['error_warning'] = $this->error['warning'];
   } else {
    $data['error_warning'] = '';
   }

   if (isset($this->error['email'])) {
    $data['error_email'] = $this->error['email'];
   } else {
    $data['error_email'] = '';
   }

   if (isset($this->error['username'])) {
    $data['error_username'] = $this->error['username'];
   } else {
    $data['error_username'] = '';
   }

   if (isset($this->error['password'])) {
    $data['error_password'] = $this->error['password'];
   } else {
    $data['error_password'] = '';
   }  

   $data['action'] = site_url('install/step_3');

   if (isset($this->request->post['username'])) {
    $data['username'] = $this->request->post['username'];
   } else {
    $data['username'] = 'admin';
   }

   if (isset($this->request->post['password'])) {
    $data['password'] = $this->request->post['password'];
   } else {
    $password = $data['password'] = '';
   }

   if (isset($this->request->post['email'])) {
    $data['email'] = $this->request->post['email'];
   } else {
    $data['email'] = '';
   }  

   $data['back'] = site_url('/');

   $data['header'] = $this->load->view('common/header', $data, true);
   $data['footer'] = $this->load->view('common/footer', null, true);

   $this->load->view('install/step_3', $data);
  
}

private function validate() {
  if (!$this->request->post['username']) {
   $this->error['username'] = $this->lang->line('error_username');
  }

  if (!$this->request->post['password']) {
   $this->error['password'] = $this->lang->line('error_password');
  }

  if ((utf8_strlen($this->request->post['email']) > 96) || !preg_match('/^[^\@]+@.*\.[a-z]{2,6}$/i', $this->request->post['email'])) {
   $this->error['email'] = $this->lang->line('error_email');
  }

  return !$this->error;
}
}


Messages In This Thread
[SOLVED] Callback Error Message Not Showing Where Should Be - by El Forum - 07-21-2014, 06:57 AM



Theme © iAndrew 2016 - Forum software by © MyBB