This is what Ive started with but I need guidance coz it does not work;
The table only has 4 columns (1) user_id (2) date_reg (3) user_name (4) pass_word
This is the Controller.
php
defined(‘BASEPATH’) OR exit(‘No direct script access allowed’);
class RegisterUser extends CI_Controller
{
public function index()
{
$this->load->library(‘session’);
$this->load->helper(array(‘form’,‘url’,‘file’));
{
$this->load->view(‘registeruser’);
}
else
{
$username = $this->input->post(‘username’);
$password = $this->input->post(‘password’);
$this->load->model(‘Username_Model’, ‘username_model’);
$result = $this->username_model->insert_user($username, $password);
$userdata = array(‘user_id’ => $result);
$userdata[‘success’] = TRUE;
$userdata = $user_name;
}
}
}
And this is the Model.
php
defined(‘BASEPATH’) OR exit(‘No direct script access allowed’);
class Username_Model extends CI_Model
{
function __construct()
{
parent::__construct();
$this->load->database();
}
public function insert_user($username, $password)
{
$userdata = array(‘user_name’=> $username, ‘pass_word’=> $password);
$this->db->update(‘tbl_member’, $userdata);
}
public function is_name_exist($username)
{
$this->db->select(’*’);
$this->db->where(‘user_name’, $username);
$query = $this->db->get(‘tbl_member’);
if ($query->result())
return TRUE;
else
return FALSE;
}
public function is_name_pass_exist($username, $password)
{
$this->db->select(‘user_id’);
$this->db->where(‘user_name’, $username);
$this->db->where(‘pass_word’, $password);
$query = $this->db->get(‘tbl_member’);
if($query->result())
return TRUE;
else
return FALSE;
}
public function getUserInfo($username)
{
//get all info
$this->db->select(’*’);
$this->db->where(‘user_name’, $username);
$result = $this->db->get(‘tbl_member’);
$row = $result->row();
return $row;
}
}
Can somebody please correct the coding where it is wrong?
Apology if the coding is not wrapped - Everything Ive tried wont work.