[eluser]zyddee[/eluser]
Hi!
I cant get the form validation to work..
It dosent post any validation errors nor re-populating the form,
what im doing wrong plz?
controller:
Code:
class Signup extends Controller {
function __construct()
{
parent::Controller();
}
function index()
{
$this->load->helper('form');
$this->load->library('form_validation');
$this->template->write_view('content', 'welcome', $data);
$this->template->write_view('content', 'signup', $data);
$this->form_validation->set_rules('username', 'Username', 'required');
$this->form_validation->set_rules('password', 'Password', 'required');
$this->form_validation->set_rules('password2', 'Password Confirmation', 'required');
$this->form_validation->set_rules('email', 'Email', 'required');
if ($this->form_validation->run() == FALSE)
{
$this->template->render();
}
else
{
redirect('start');
}
}
}
view:
Code:
<?php echo validation_errors(); ?>
<?php echo form_open('signup'); ?>
<table>
<tr>
<td>Your Name</td>
<td><input type="text" value="<?php echo set_value('name'); ?>" id="name" name="name" /></td>
</tr>
<tr>
<td>Username</td>
<td><input type="text" value="<?php echo set_value('username'); ?>" id="username" name="username" /></td>
</tr>
<tr>
<td>Password</td>
<td><input type="password" value="<?php echo set_value('password'); ?>" id="password" name="password" /></td>
</tr>
<tr>
<td>Confirm Password</td>
<td><input type="password" value="<?php echo set_value('password2'); ?>" id="password2" name="password2" /></td>
</tr>
<tr>
<td>E-mail</td>
<td><input type="password" value="<?php echo set_value('email'); ?>" id="email" name="email" /></td>
</tr>
<tr>
<td></td>
<td>
<input type="submit" value="Submit Registration" />
</td>
</tr>
</table>
</form>
Best Regards!