Welcome Guest, Not a member yet? Register   Sign In
Problem with Routing and dveloping a Registration form in CI
#1

[eluser]Unknown[/eluser]
Hi Guys,

Please I need a hand on this:

(1) Controller is - my_account (my_account.php)
(2) model is - my_account_model.php
(3) action or method called is - register()
(4) View is - register.php
(5) url address is - myweb/my_account/register

Im having this error page, the page won't load on the browser.
Code:
Unable to locate the model you have specified: my_account_model


Here is my controller code
Code:
<?php

class My_account extends CI_Controller {

// Start new shopping session for guest
    public function __construct()
       {
            parent::__construct();
            // initializing session
           $this->load->library('session');
          // loading model for products on Sale
          $this->load->model('my_account_model');
          //$this->load->database();
        
       }

     public  function register(){
    // $this->load->helper('form');
$this->load->library('form_validation');

$data['title'] = 'Register for a New Customer Account';

$this->form_validation->set_rules('fname', 'Firstname', 'required');
$this->form_validation->set_rules('lname', 'Lastname', 'required');

if ($this->form_validation->run() === FALSE)
{
  $this->load->view('templates/header.wtp', $data);
  $this->load->view('my_account/register.php');
  $this->load->view('templates/footer.wtp');
  
}
else
{
  $this->my_account_model->create();
  $this->load->view('my_account/success.wtp');
}
       }
      
      
?>


And here is my model code
Code:
<?php
class My_account_model extends CI_Model {

public function __construct()
{
  $this->load->database();
}

/**
  *
  * Static Registration
  */
public function create()
{
   $md5 = $this->input->post('pword');
   $encrypt_pwd=md5($md5);
$data = array(
  'firstname' => $this->input->post('fname'),
  'lastname' => $this->input->post('lname'),
        'email' => $this->input->post('email'),
        'password' => $encrypt_pwd,
  'phone' => $this->input->post('phone'),
  'mobile'=> $this->input->post('mobile')
     );
return $this->db->insert('customers',$data);

      /*  Set up address */            
$flat = $this->input->post('flat');
$email= $this->input->post('email');
$buildings = $this->input->post('building');
$steet1 = $this->input->post('street1');
$street2 =$this->input->post('street2');
$city = $this->input->post('city');
$county = $this->input->post('county');
$postcode = $this->input->post('postcode');
$country = $this->input->post('country');


// Set address details
$sql = "INSERT INTO addresses SET address_key='$email', house_number_flat='$flat',building='$building',street1='$street1', street2='$street2',city='$city',county='$county',postcode='$postcode',country='$country'";
return  $this->db->query($sql);
  
}
}



?>

and here is my Route config for this task

Code:
// Routing for customer register
$route['my_account/register'] = 'my_account/register';
$route['my_account'] = 'my_account';

Please include directory names in your solutions so I could compare it with my work.

Many thanks

Looking forward to your posts



#2

[eluser]InsiteFX[/eluser]
Do not use my_ codeigniter uses it for MY_ unless you change it in config.php

#3

[eluser]TheFuzzy0ne[/eluser]
Your __construct method needs to call parent::__construct().




Theme © iAndrew 2016 - Forum software by © MyBB