I am new to the codeigniter and i am trying its tutorials from the user guide. But i just got stuck in one place. In the code of the form validations. I am trying its example for the set_value property but my user text box is not returning anything.
In my view i added the following code:
<?php echo validation_errors();?>
<?php echo form_open('form');?>
<table border="0">
<tr>
<td><h5>Username</h5></td>
<td><input type="text" name="username" value="" size="50" value="<?php echo set_value('username'); ?>" /></td>
</tr>
<tr>
<td><h5>Password</h5></td>
<td><input type="password" name="password" value="" size="50" accept=" <?php echo set_value('password'); ?>" /></td>
</tr>
<tr>
<td><h5>password Confirm</h5></td>
<td><input type="password" name="passconf" value="" size="50" /></td>
</tr>
<tr>
<td><h5>Email Addres</h5></td>
<td> <input type="text" name="email" value="" size="50" accept="<?php echo set_value('email'); ?>" /></td>
</tr>
<tr>
<td> </td>
<td><div><input type="submit" value="Submit" /></div></td>
</tr>
</table>
</form>
and in my controller i added the following code:
function index()
{
$this->load->helper(array('form', 'url'));
$this->load->library('form_validation');
$this->form_validation->set_rules('username','username','required|min_length[5]|max-length[10]|xss_clean');
$this->form_validation->set_rules('password','password','required');
$this->form_validation->set_rules('passconf','password confirmation','required');
$this->form_validation->set_rules('email','email','required');
if ($this->form_validation->run() == FALSE)
{
$this->load->view('myform');
}
else
{
$this->load->view('formsucces');
}
}
Thank You in advance.
There are two value attributes in your input type..
Try this…