[eluser]amira_fcis[/eluser]
i tried to make update user information,in case of user didn't fill the required fields the form_avalidation will report an error.
here is the problem
when the user didn't fill the required fields nothing happened i donot know why ?!!!!
here is the function
Code:
function updateUser()
{
$this->load->database();
$this->load->library('form_validation');
$this->load->helper(array('form', 'url'));
$this->load->model('User');
$userServices=new UserServices();
$userDAO = new UserDAO();
$this->form_validation->set_rules('username', 'Username', 'required|min_length[5]|max_length[12]');
$this->form_validation->set_rules('firstname', 'First Name', 'required|min_length[5]|max_length[12]');
$this->form_validation->set_rules('lastname', 'Last Name', 'required|min_length[5]|max_length[12]');
$this->form_validation->set_rules('title', 'Title', 'min_length[2]|max_length[5]');
$this->form_validation->set_rules('email', 'Email', 'required|valid_email');
$this->form_validation->set_rules('password', 'Password', 'required|matches[confirmpassword]');
$this->form_validation->set_rules('confirmpassword', 'Password Confirmation', 'required');
$this->form_validation->set_rules('city', 'City', 'required');
$this->form_validation->set_rules('phoneno', 'Phone No', 'min_length[5]|max_length[12]');
$this->form_validation->set_rules('cellphoneno', 'Cell Phone No', 'required|min_length[5]|max_length[12]');
if ($this->input->post('submit') && ! $this->form_validation->run())
{
[b]
$this->User->setUserID($this->input->post('userid'));
$data['users']=$userDAO->retrieveUser( $this->User,$this);
[/b]
$this->load->view('Edit_form',$data);
}
note--> the bold code i guess it causes the problem because i tried before without this 2 lines and it worked probably but here i need to retrieve user information again with any errors that user made.
here is the form
Code:
<html>
<head>
<title>Edit Form</title>
</head>
<body>
<?php echo validation_errors(); ?>
<?php echo form_open('EditUser/updateUser'); ?>
<?
if($users)
{
foreach( $users as $user)
{
?>
<input type="hidden" name="userid" value="<?echo $user->getUserID() ;?>" size="50" />
<?php echo form_error('username'); ?>
User Name <input type="text" name="username" value="<?echo $user->getUserName() ;?>"/><br><br>
<?php echo form_error('firstname'); ?>
First Name <input type="text" name="firstname" value="<?echo $user->getUserFName() ;?>"/><br><br>
<?php echo form_error('lastname'); ?>
Last Name <input type="text" name="lastname" value="<?echo $user->getUserLName() ;?>" /><br><br>
<?php echo form_error('title'); ?>
Title <input type="text" name="title" value="<?echo $user->getUserTitle() ;?>" /><br><br>
<?php echo form_error('email'); ?>
Email <input type="text" name="email" value="<?echo $user->getUserEmail() ;?>" /><br><br>
<?php echo form_error('password'); ?>
Password <input type="password" name="password" value="<?echo $user->getUserPassword() ;?>" /><br><br>
<?php echo form_error('confirmpassword'); ?>
Confirm Password <input type="password" name="confirmpassword" value="" /><br><br>
Address <input type="text" name="address" value="<?echo $user->getUserAddress() ;?>" /><br><br>
<?php echo form_error('city'); ?>
City <input type="text" name="city" value="<?echo $user->getUserCity() ;?>" /><br><br>
<?php echo form_error('phoneno'); ?>
Phone No <input type="text" name="phoneno" value="<?echo $user->getUserPhoneNo() ;?>"/><br><br>
<?php echo form_error('cellphoneno'); ?>
Cell-Phone No <input type="text" name="cellphoneno" value="<?echo $user->getUserCellPhoneNo() ;?>"/><br><br>
<?
}
}
?>
<input type="submit" name="submit" value="Update" />
</form>
</body>
</html>
i'll be soooooooooo greatfull for any help