Welcome Guest, Not a member yet? Register   Sign In
How to re-populate the form with values from the database?
#7

[eluser]Unknown[/eluser]
I suggest the following method for filling the form fields with database values.

Code:
if(!empty($_POST)){

       //just for understanding
       $_POST['user_email'] = $_POST['user_email'];

}else{
       // Set post vars with db values
       $data['user'] = $this->users_model->get_user($user_id);
       $_POST['user_email'] = $data['user']['user_email'];
}

in this way, the form is filled with the DB data, or when the user changed the data, submitted, but a error occured, the form is filled again but now with the data from the POST.


Messages In This Thread
How to re-populate the form with values from the database? - by El Forum - 03-24-2012, 05:49 AM



Theme © iAndrew 2016 - Forum software by © MyBB