Welcome Guest, Not a member yet? Register   Sign In
how to set email validation.
#11

[eluser]kit005[/eluser]
Heres my controller


Code:
<?php
class educ extends CI_Controller
{
public function __construct()
{
  parent::__construct();
  $this->load->library('form_validation');
  $this->load->helper(array('form', 'url'));
  
  $this->load->model('demo_model');
}
public function index()
{
  $this->load->view('demo/index');
  
}

public function view2()
{
  session_start();
  $_SESSION['contractno'] = $_REQUEST['contractno'];
  $queryr['details'] = $this->demo_model->demodb($_SESSION['contractno']);
  
  if (count($queryr['details'])>0)
  {
       $this->load->view('demo/view2', $queryr);
  }
  else
  {
   //echo "[removed]alert('No Record found');[removed]";
   $this->load->view('demo/index');
  }
  
  
}

public function display()
{
  session_start();
  $cno = $_SESSION['contractno'];
  /*$_SESSION['sname'] = $_REQUEST['sname'];
  $_SESSION['fname'] = $_REQUEST['fname'];
  $_SESSION['mi'] = $_REQUEST['mi'];
  $_SESSION['dob'] = $_REQUEST['dob'];
  $_SESSION['contractdate'] = $_REQUEST['contractdate'];*/
  $queryr['details'] = $this->demo_model->demodb($cno);
  $this->load->view('demo/display', $queryr);
  
}

public function display2()
{
  session_start();
  $cno = $_SESSION['contractno'];
  $_SESSION['neweadd'] = $_REQUEST['eadd'];
  $_SESSION['newcpnum'] = $_REQUEST['cpnum'];
  $_SESSION['newcpprefix'] = $_REQUEST['cpprefix'];
  $queryr['details'] = $this->educ_model->educplan($cno);
  $queryr['beneficiary'] = $this->demo_model->beneficiary($cno);
  //print_r($queryr);
  $this->load->library('form_validation');
  $this->form_validation->set_rules('eadd', 'Email', 'required|valid_email|is_unique');
  if ($this->form_validation->run() == FALSE)
  {
   echo "[removed]alert('Email address not valid');[removed]";
   $this->load->view('demo/display', $queryr);
                }
  else
  {
   //echo "[removed]alert('Suc');[removed]";
   $this->input->post('eadd');
   $this->load->view('demo/display2',$queryr);

  }
  
    
  
}

public function save()
{
  session_start();
  $cntno = $_SESSION['contractno'];
  $educdata = array(
                        
                        'cpprefix' => $_SESSION['newcpprefix'],
                        'cpnum' => $_SESSION['newcpnum'],
                        'eadd' => $_SESSION['neweadd']
                        );
  //print_r($demodata);
  $this->demo_model->savechanges($demodata,$cntno);
  echo "[removed]alert('DATA UPDATED!!!');[removed]";
  $this->load->view('demo/cert');
  
}
}


my demo_model:

Code:
<?php
class educ_model extends CI_Model
{

public function __construct()
{
           /*$host = $_SERVER['REQUEST_URI'];
  if (strpos($host,'beta')>0)
   $this->load->database();
  else
   $this->load->database('prod');*/
  $this->defaultdb = $this->load->database('default');
  $this->webtest = $this->load->database('webtest');
                $this->prod = $this->load->database('prod');
  $this->oratest = $this->load->database('oratest');
                $this->newntr = $this->load->database('newntr');
}
        public function demodb($contractnum=false)
        {
  $this->db->select('*');
  $this->db->from('demodb');
                $this->db->where('contractno',$contractnum);
  $q = $this->db->get();
                return $q->result_array();
        }
public function beneficiary($cno=false)
        {
  $this->db->select('*');
  $this->db->from('beneficiary');
                $this->db->where('contractno',$cno);
  $bf = $this->db->get();
                return $bf->result_array();
        }
public function savechanges($demodata=array(), $cntno=false)
{
     foreach($demodata as $k=>$v)
     $this->db->set($k, $v);
     $this->db->where('contractno', $cntno);
     $this->db->update('demodb');
}
}
?>
#12

[eluser]kit005[/eluser]
Found whats been missing on my codes.. its the
Code:
<?php echo validation_errors(); ?>
on my view.. Thanks guys.. Cheers :-)




Theme © iAndrew 2016 - Forum software by © MyBB