Creating basic Register (username/login/password) |
[eluser]terry101[/eluser]
so are you sayin i should change this Code: class User extends CI_Controller{ into Code: class User extends CI_Controller{ ?
[eluser]jvicab[/eluser]
this is the code you posted before. I jus changed the first two lines of your controller constructor and removed your model constructor. Try to see Controller <?php class User extends CI_Controller{ //================ I changed the fisrt to lines of your constructor function __construct() { parent::__construct(); $this->view_data[‘base_url’] = base_url(); $this->load->model(‘User_model’); } function index() { $this->register(); } function register(){ $this->load->library(‘form_validation’); $this->form_validation->set_rules(‘username’, ‘Username’, ‘required|min_length[5]|max_length[12]|xss_clean’); $this->form_validation->set_rules(‘name’, ‘Name’, ‘required|min_length[3]|max_length[20]|xss_clean’); $this->form_validation->set_rules(‘email’, ‘E-mail’, ‘required|min_length[3]|max_length[20]|xss_clean|valid_email’); $this->form_validation->set_rules(‘password’, ‘Password’, ‘required|min_length[3]|max_length[20]|xss_clean’); $this->form_validation->set_rules(‘password_conf’, ‘Re-type Password’, ‘required|min_length[3]|max_length[20]|xss_clean|matches[password]’); if ($this->form_validation->run() == FALSE) { $this->load->view(‘viewregister’); } else { $username = $this->input->post(‘username’); $name = $this->input->post (‘name’); $email = $this->input->post (‘email’); $password = $this->input->post (‘password’); ********Line 37*********** $this->Usermodel->register_user($username, $name, $email, $password); } } } Model <?php class Usermodel extends CI_Model { /// ============== I removed your the construct. It is not needed function register_user($username, $name, $email, $password) { $shal_password = shal($password); $query_str = “INSERT INTO tbregister (username, password, name, email) Value (’{$username}’, ‘{$name}’, ‘{$email}’, ‘{password}’)”; $this->db-query($query_sr, array($username,$name,$email,$shal_password)); } }
[eluser]toymachiner62[/eluser]
[quote author="terry101" date="1312596459"]so are you sayin i should change this Code: class User extends CI_Controller{ into Code: class User extends CI_Controller{ ?[/quote] It doesn't look like you even changed any thing there. I'm saying take this line Code: $this->load->model('Usermodel');
[eluser]terry101[/eluser]
oo snap it worked!!! thank you sir... i got another error tho in model. anyidea? error Fatal error: Call to undefined function shal() in C:\wamp\www\code\application\models\usermodel.php on line 10 Code: function register_user($username, $name, $email, $password) { Code: <?php
[eluser]jvicab[/eluser]
yes, that is what I am saying, but don't forget to keep the last line in your controller constructor: $this->load->model('Usermodel'); or like our friend is suggesting, move it to function register.
[eluser]terry101[/eluser]
its a encryption, hmm should i use md5 encryption instead? how would that look $password = md5($password);? below from the user guide Code: $hash = sha1('Some string'); http://ellislab.com/codeigniter/user-gui...ption.html
[eluser]jvicab[/eluser]
check your code, seem to me you placed a "l" (lowercase L) instead of "1" (number 1) in the name of the function
[eluser]terry101[/eluser]
yea it was i made a error...good eye. i got a error on line 14? almost there :-) ! ) Fatal error: Call to undefined function query() in C:\wamp\www\code\application\models\usermodel.php on line 14 Line 14 Code: $this->db-query($query_str, array($username,$name,$email,$sha1_password)); Code: <?php |
Welcome Guest, Not a member yet? Register Sign In |