Welcome Guest, Not a member yet? Register   Sign In
Help with User Registration Function?
#1

[eluser]Corey Freeman[/eluser]
Hey,

So this is my first attempt at building something with code igniter, and just for reference, I'm trying to make a browser RPG game. The first thing I want to get done is user registration, and this is the code I have in my registration controller:

Code:
<?php

class Form extends Controller {
    
    function index()
    {
        $this->load->helper(array('form', 'url'));
        $this->load->view('header');
        
        $this->load->library('form_validation');
            
$this->form_validation->set_rules('username', 'Username', 'callback_username_check');
$this->form_validation->set_rules('password', 'Password', 'required|matches[passconf]');
$this->form_validation->set_rules('passconf', 'Password Confirmation', 'required');
$this->form_validation->set_rules('email', 'Email', 'required|valid_email');
            
        if ($this->form_validation->run() == FALSE)
        {
            $this->load->view('register');
        }
        else
        {
        //show the form success
        redirect('form/success/');
        }
    }
        function username_check($str) {
        $this->db->select('username');
        $query = $this->db->get('players');
        if ($str == 'test')
        {
            $this->form_validation->set_message('username_check', 'The %s field can not be the word "test"');
            return FALSE;
        }
        else
        {
            return TRUE;
        }
    }
    function success() {
        $this->load->view('formsuccess');
    }
    function register_player() {
    //Register!
        $username = $_POST['username'];
        $password = $_POST['password'];
        $email = $_POST['email'];
        $data = array(                
        'id' => DEFAULT,
        'username' => $username ,
        'password' => $password ,
        'email' => $email
        );
        $this->db->insert('players', $data);
        redirect('form/success/');
    }
}
?>

Right now this just gives me a blank page. I need help putting the form information into the database and checking the username input against the usernames in the database. Any suggestions? :bug:


Messages In This Thread
Help with User Registration Function? - by El Forum - 07-02-2010, 06:31 AM
Help with User Registration Function? - by El Forum - 07-02-2010, 07:30 AM
Help with User Registration Function? - by El Forum - 07-02-2010, 08:00 AM
Help with User Registration Function? - by El Forum - 07-02-2010, 11:47 AM
Help with User Registration Function? - by El Forum - 07-02-2010, 12:22 PM
Help with User Registration Function? - by El Forum - 07-02-2010, 12:23 PM
Help with User Registration Function? - by El Forum - 07-02-2010, 02:46 PM
Help with User Registration Function? - by El Forum - 07-02-2010, 02:51 PM
Help with User Registration Function? - by El Forum - 07-02-2010, 04:20 PM
Help with User Registration Function? - by El Forum - 07-02-2010, 06:36 PM
Help with User Registration Function? - by El Forum - 07-03-2010, 03:29 AM
Help with User Registration Function? - by El Forum - 07-03-2010, 06:29 AM
Help with User Registration Function? - by El Forum - 07-04-2010, 06:30 AM



Theme © iAndrew 2016 - Forum software by © MyBB