Welcome Guest, Not a member yet? Register   Sign In
GamingFusion
#1

[eluser]GamingFusion[/eluser]
I have started to develop the core parts of my site with CodeIgniter, and i have gotten a register script to work,but i need to get it to check to make sure the passwords and email address are the same. i was wandering how i could do that. thanks in advance.

heres me register.php view file script and my controller function for it.

Register Function
Code:
function register ()
    {
        $data['title'] = "GamingFusion | Register";
        $data['header'] = "Register";
        $data['query'] = $this->db->get('users');
        
        $this->load->view('register', $data);
    }
    
    function register_insert ()
    {
        $this->db->insert('users', $_POST);    
        
        redirect('site');

register.php view file

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
&lt;html &gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
&lt;title&gt;&lt;?=$title?&gt;&lt;/title&gt;
&lt;link rel="stylesheet" type="text/css" href="http://site.gamingfusion.net/css/feed.css"&gt;
&lt;/head&gt;
<h1>&lt;?=$header?&gt;</h1>

&lt;?=form_open('site/register_insert');?&gt;

<p>First Name</p>
<p>&lt;input type="text" name="first" /&gt;&lt;/p>
<p>Last Name</p>
<p>&lt;input type="text" name="last" /&gt;&lt;/p>
<p>Username</p>
<p>&lt;input type="text" name="username" /&gt;&lt;/p>
<p>Password</p>
<p>&lt;input type="text" name="password" /&gt;&lt;/p>
<p>&lt;input type="text" name="password" /&gt;&lt;/p>
<p>Email</p>
<p>&lt;input type="text" name="email" /&gt;&lt;/p>
<p>&lt;input type="text" name="email" /&gt;&lt;/p>
<p>&lt;input type="submit" value="Register" /&gt;&lt;/p>

&lt;/form&gt;

&lt;/body&gt;
&lt;/html&gt;
#2

[eluser]be3_[/eluser]
Read form validation in user manual.

Code:
$this->form_validation->set_rules('password', 'Password', 'required|matches[passconf]');
$this->form_validation->set_rules('passconf', 'Password Confirmation', 'required');
#3

[eluser]GamingFusion[/eluser]
thanks i didn't see that class
#4

[eluser]GamingFusion[/eluser]
Ok i have put it in and have went through the user guide but no mater what i enter the validation of the form is not using my rules.

heres my function

Code:
function register ()
    {
        
        $data['query'] = $this->db->get('users');
        
        $this->load->library('form_validation');
            
        $this->form_validation->set_rules('first', 'First Name', 'required');
        $this->form_validation->set_rules('last', 'First Name', 'required');
        $this->form_validation->set_rules('username', 'Username', 'required|min_length[5]|max_length[15]');
        $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|required|matches[emailconf]');
        $this->form_validation->set_rules('emailconf', 'Email Confirmation', 'required');
        
        if ($this->form_validation->run() == FALSE)
        {
            $this->load->view('register');
        }
        else
        {
            $this->load->view('regsuccess');
        }


}
#5

[eluser]be3_[/eluser]
Change your html code and all will work fine +)
#6

[eluser]GamingFusion[/eluser]
ok what do you mean bt my html heres my view file if thats what ur talking about.

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
&lt;html &gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
&lt;title&gt;GamingFusion R?egistration&lt;/title&gt;
&lt;link rel="stylesheet" type="text/css" href="http://site.gamingfusion.net/css/feed.css"&gt;
&lt;/head&gt;
<h1>Registration</h1>(required *)
&lt;?php echo validation_errors(); ?&gt;

&lt;?php echo form_open('site/register_insert'); ?&gt;

<h4>First Name *</h4>
&lt;input type="text" name="first" value="" size="50" /&gt;

<h4>Last Name *</h4>
&lt;input type="text" name="last" value="" size="50" /&gt;

<h4>Username(Min of 5 Max of 15) *</h4>
&lt;input type="text" name="username" value="" size="50" /&gt;

<h4>Password *</h4>
&lt;input type="password" name="password" value="" size="50" /&gt;

<h4>Password Confirm *</h4>
&lt;input type="password" name="passconf" value="" size="50" /&gt;

<h4>Email Address(Valid Email) *</h4>
&lt;input type="text" name="email" value="" size="50" /&gt;

<h4>Email Confirm *</h4>
&lt;input type="text" name="emailconf" value="" size="50" /&gt;

<p>&lt;input type="submit" value="Register" /&gt;&lt;/p>

&lt;/form&gt;

&lt;/body&gt;
&lt;/html&gt;
#7

[eluser]be3_[/eluser]
This code work fine.

if validation false, controller load "register" view
if true, regsuccess
#8

[eluser]GamingFusion[/eluser]
but it's not doing that though, it's just submitting it and going to the regsuccess page, even if it's wrong
#9

[eluser]jcopling[/eluser]
If I'm reading your code correctly it looks like the HTML form is posting to the register_insert function but your validation is location inside the register function.

Check that and it looks like everything should work.
#10

[eluser]GamingFusion[/eluser]
ok i redid the entire thing and now when i go to register i get this message what does it mean?

Quote:A Database Error Occurred

Error Number: 1054

Unknown column 'password' in 'field list'

INSERT INTO `users` (`first`, `last`, `username`, `password`, `passconf`, `email`, `emailconf`) VALUES ('Chad', 'Gregory', 'test', 'password', 'password', '[email protected]', '[email protected]')




Theme © iAndrew 2016 - Forum software by © MyBB