Welcome Guest, Not a member yet? Register   Sign In
Optional Default Value
#2

You could create a $first_name and $last_name variable before the form that takes the POST data if available, else take the session data. This would be for if you refresh the same page on form submit.

Something like this
PHP Code:
<?php
$first_name 
= ($this->input->post('first_name')) ?: $this->session->userdata('logged_in')['first_name']; 
$last_name  = ($this->input->post('last_name')) ?: $this->session->userdata('logged_in')['last_name']; 
?>
<div class="container">
    <div class="panel panel-default">
          <div class="panel-heading">Edit Profile</div>
              <div class="panel-body">
                  <div class="row">
                      <div class="col-xs-5">
                        <?php echo validation_errors(); ?>
                           <?php echo form_open('profile/edit'); ?>
                        <div class="form-group">
                            <label for="first_name">First Name:</label>
                            <input type="text" class="form-control" id="first_name" name="first_name" value="<?php echo set_value('first_name'$first_name); ?>" />
                        </div>
                        <div class="form-group">
                             <label for="last_name">Last Name:</label>
                            <input type="text" class="form-control" id="last_name" name="last_name" value="<?php echo set_value('last_name'$last_name); ?>" />
                        </div>
                        <div class="form-group">
                            <input type="submit" class="btn btn-primary" value="Edit Profile" />
                        </div>
                        </form>
                    </div>
                </div>
        </div>
        <div class="panel-footer text-right">Page rendered in <strong>{elapsed_time}</strong> seconds!</div></div>
    </div>
</div> 
Reply


Messages In This Thread
Optional Default Value - by miiikkeyyyy - 02-28-2015, 09:24 AM
RE: Optional Default Value - by silentium - 02-28-2015, 01:00 PM
RE: Optional Default Value - by miiikkeyyyy - 03-01-2015, 06:08 AM
RE: Optional Default Value - by silentium - 03-01-2015, 04:11 PM
RE: Optional Default Value - by RobertSF - 02-28-2015, 04:49 PM
RE: Optional Default Value - by SomeGuy - 02-28-2015, 07:37 PM



Theme © iAndrew 2016 - Forum software by © MyBB