[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">
<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?=$title?></title>
<link rel="stylesheet" type="text/css" href="http://site.gamingfusion.net/css/feed.css">
</head>
<h1><?=$header?></h1>
<?=form_open('site/register_insert');?>
<p>First Name</p>
<p><input type="text" name="first" /></p>
<p>Last Name</p>
<p><input type="text" name="last" /></p>
<p>Username</p>
<p><input type="text" name="username" /></p>
<p>Password</p>
<p><input type="text" name="password" /></p>
<p><input type="text" name="password" /></p>
<p>Email</p>
<p><input type="text" name="email" /></p>
<p><input type="text" name="email" /></p>
<p><input type="submit" value="Register" /></p>
</form>
</body>
</html>
[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');
[eluser]GamingFusion[/eluser]
thanks i didn't see that class
[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');
}
}
[eluser]be3_[/eluser]
Change your html code and all will work fine +)
[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">
<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>GamingFusion R?egistration</title>
<link rel="stylesheet" type="text/css" href="http://site.gamingfusion.net/css/feed.css">
</head>
<h1>Registration</h1>(required *)
<?php echo validation_errors(); ?>
<?php echo form_open('site/register_insert'); ?>
<h4>First Name *</h4>
<input type="text" name="first" value="" size="50" />
<h4>Last Name *</h4>
<input type="text" name="last" value="" size="50" />
<h4>Username(Min of 5 Max of 15) *</h4>
<input type="text" name="username" value="" size="50" />
<h4>Password *</h4>
<input type="password" name="password" value="" size="50" />
<h4>Password Confirm *</h4>
<input type="password" name="passconf" value="" size="50" />
<h4>Email Address(Valid Email) *</h4>
<input type="text" name="email" value="" size="50" />
<h4>Email Confirm *</h4>
<input type="text" name="emailconf" value="" size="50" />
<p><input type="submit" value="Register" /></p>
</form>
</body>
</html>
[eluser]be3_[/eluser]
This code work fine.
if validation false, controller load "register" view
if true, regsuccess
[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
[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.
[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]')
|