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

[eluser]Unknown[/eluser]
this is the register page
<h1>Register Your Childrens Book Account Free</h1>



&lt;?php echo validation_errors(); ?&gt;

&lt;?php echo form_open('page/register'); ?&gt;



<p>Username: </p>

<p>&lt;input type="text" name="username"

value="&lt;?php echo set_value('username'); ?&gt;" &lt;/p>

<p>&lt;?php echo form_error ('username'); ?&gt; </p>



<p>Email: </p>

<p>&lt;input type="text" name="email"

value="&lt;?php echo set_value('email'); ?&gt;" &lt;/p>

<p>&lt;?php echo form_error ('email'); ?&gt; </p>



<p>Password: </p>

<p>&lt;input type="password" name="password"

value="&lt;?php echo set_value('password'); ?&gt;" &lt;/p>

<p>&lt;?php echo form_error ('password'); ?&gt; </p>



<p>Password Confirmation: </p>

<p>&lt;input type="password" name="password_conf"

value="&lt;?php echo set_value('password_conf'); ?&gt;" &lt;/p>

<p>&lt;?php echo form_error ('password_conf'); ?&gt; </p>

<p>&lt;input type="submit" name="submit"

value="Register Account"/&gt;&lt;/p>

and the part of my controller that validates registeration
function register()
{
$this->form_validation->
set_rules('username', 'Username', 'xss_clean|required');

$this->form_validation->
set_rules('email', 'Email Address',
'xss_clean|required|valid_email|callback_email_exists');

$this->form_validation->set_rules('password', 'Password', 'xss_clean|required|min_length[4]|max_length[12]|matches[password_conf]
|sha1');

$this->form_validation->
set_rules('password_conf', 'Password Confirmation',
'xss_clean|required|matches[password]|sha1');

if ($this->form_validation->run() == FALSE)
{
$this->load->view('page/register');
}
else {
$data['username'] = $this->input->post('username');
$data['email'] = $this->input->post('email');
$data['password'] =
sha1($this->_salt . $this->input->post('password'));

if ($this->account_model->create($data) ===TRUE)
{
$data['message'] =
"The user account has been successfully created "
. anchor ('page/login', 'here') . ".";
$this->load->view('page/success', $data) ;
}
else {
$data['$error'] =
"There was a problem when creating your account.";
$this->load->view('page/error', $data);
}
}
}

when completing the registration form it should validate on my controller and call the model however for some reason its not could anyone help.


#2

[eluser]InsiteFX[/eluser]
Please wrap your code in code tags! Look at all your quotes...

Code:
// remove the space inside the tags!
[code ]
    // your code here!
[/code ]
#3

[eluser]Unknown[/eluser]
on which file do you mean
#4

[eluser]Mauricio de Abreu Antunes[/eluser]
He said you need to put your code between code tags. Like this:
Code:
echo 'Hello World!';




Theme © iAndrew 2016 - Forum software by © MyBB