0

I have simple form that allows the user to change their password. I am using the codeigniter framework form validation tools to check if the user correctly entered their current password and if the new password is acceptable and if the confirmation password matches the new password. Three fields in all. I'm also using the repopulation tool to repopulate the fields if there was a mistake.

If the correctly enter everything I have the form display the same form with a message at the bottom that says Password has been changed. However, the data that was entered remains there. I've tried doing a redirect to the same form but then I can't have the confirmation message.

What I really want to know is there a way to delete or clear the data that is I the repopulation variables. So that when the form is completed, the form has no values to put back into those fields

speck1990
  • 127
  • 1
  • 12
  • 1
    Could you post applicable code for your controller, model, and view? Also maybe let us know what you've tried that isn't in the code? Otherwise it's pretty hard to help you. – Craine Mar 08 '15 at 22:11
  • 1
    well another angle on this -- do not repopulate the password fields at all. IMNSHO password and credit card fields should never be repopulated, there's too many potential security issues. – cartalot Mar 08 '15 at 23:04
  • @cartalot Good point, especially if he isn't using HTTPS to secure the connection. Additionally, when it comes to password changing forms, it's probably of dubious value to actually repopulate the fields if there was something wrong, since at least one of the fields that is filled in will be wrong. – Craine Mar 08 '15 at 23:08
  • That is a good point. Passwords could actually afford not to be depopulated. I think I actually settled on having it go to a confirmation page instead. So it leaves the page completely. – speck1990 Mar 09 '15 at 02:13

2 Answers2

0

You can redirect to page with some GET parmeter, like www.example.com/change_pass?success=true. Then, above the form: <?php if($this->input->get('succes')) echo 'Confirmation message.';?>

Vali S
  • 1,471
  • 2
  • 10
  • 18
0

Although I am not too familiar with Code Igniter, but I think for this task you should use sessions. More particularly I think flash messages will suit the task. See How to display error messages in CodeIgniter and CodeIgniter Flash Data. I think should solve your problem

Community
  • 1
  • 1
DaGhostman Dimitrov
  • 1,608
  • 20
  • 44