Welcome Guest, Not a member yet? Register   Sign In
Repopulating a form from session data
#1

[eluser]Jesse Schutt[/eluser]
Hi guys,

I know that this is a fairly simple question, but I don't know the syntax to accomplish it!

Code:
<label for="first_name">First Name <span class="required">*</span></label>
&lt;input id="first_name" type="text" name="first_name" value="&lt;?php echo set_value('first_name'); ?&gt;"  /&gt; &lt;?php echo form_error('first_name'); ?&gt;

What I'd like to do is have the form check if the 'first_name' is set in the user's session. If it is set, then I'd like it to be in the set_value. If it is not set, I'd like it to be blank (unless it is being validated...)

Thanks Much!!

Jesse
#2

[eluser]Ben Edmunds[/eluser]
Do you not want to use the validation class?
#3

[eluser]Jesse Schutt[/eluser]
Ben,

Yes, I'm using the validation. I actually just figured out how to do it using

Code:
&lt;?php echo set_value('first_name', $this->session->userdata('first_name'); ?&gt;

Thanks!
#4

[eluser]skunkbad[/eluser]
set_value() comes from the form validation, so :

Code:
&lt;?php
if ($this->form_validation->run() != FALSE)
{        {
     if($this->session->userdata('item'))
     {
          $data['item'] = $this->session->userdata('item');
     }
     else
     {
          $data['item'] = set_value('item');
     }
}
else
{
     if( ! array_key_exists('item',$this->form_validation->_error_array)))
     {
          if($this->session->userdata('item'))
          {
               $data['item'] = $this->session->userdata('item');
          }
     }
}




Theme © iAndrew 2016 - Forum software by © MyBB