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

I am new to CodeIgniter, I love it! So simple!
I'm getting to know the basics so I'm creating a user management system.
Logging in, out and registering all works fantastic.

I am currently working on the editing of the profile.
I want the default value of the input fields to be the session variable of first_name and last_name however if the form has been posted I want the default value to be the post variable instead.

This is my application/views/profile/edit.php.
PHP Code:
<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'$this->session->userdata('logged_in')['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'$this->session->userdata('logged_in')['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> 

I hope I have made this easy enough to understand,
Thank you in advance!
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