Welcome Guest, Not a member yet? Register   Sign In
Help form some basics
#1

[eluser]Unknown[/eluser]
Hellow, I'm new user of codeigniter and just started with php and that stuffs. I have some basic questions about forms and connect to database with model, etc. I'll show on examples:

View:
Code:
&lt;?php echo validation_errors('<p class="error">'); ?&gt;
&lt;?php echo form_open("user/registration"); ?&gt;
  <p>
   <label for="user_name">Username:</label>
   &lt;input type="text" id="user_name" name="user_name" value="&lt;?php echo set_value('user_name'); ?&gt;" /&gt;
  </p>        
  <p>
   <label for="email_address">Email:</label>
   &lt;input type="text" id="email_address" name="email_address" value="&lt;?php echo set_value('email_address'); ?&gt;" /&gt;
  </p>
  <p>
   <label for="password">Password:</label>
   &lt;input type="password" id="password" name="password" value="&lt;?php echo set_value('password'); ?&gt;" /&gt;
  </p>
  <p>
   <label for="con_password">Confirm password:</label>
   &lt;input type="password" id="con_password" name="con_password" value="&lt;?php echo set_value('con_password'); ?&gt;" /&gt;
  </p>
        <p>
            <label for="user_rname">Real name:</label>
            &lt;input type="text" id="user_rname" name="user_rname" value="&lt;?php echo set_value('user_rname'); ?&gt;" /&gt;
        </p>
        <p>
            <label for="user_rsname">Surname:</label>
            &lt;input type="text" id="user_rsname" name="user_rsname" value="&lt;?php echo set_value('user_rsname'); ?&gt;" /&gt;
        </p>
        <p>
            &lt;?php
            echo form_label('Location:', 'location');
            $options = array(
                'small'  => 'Small Shirt',
                'med'    => 'Medium Shirt',
                'large'   => 'Large Shirt',
            );
                echo form_dropdown('location', $options, 'large'); ?&gt;
        </p>
        <p>
            &lt;?php
            echo form_label('Sex:', 'sex');

            echo form_radio('sex', 'm');
            echo form_radio('sex', 'ΕΎ');
            echo form_radio('sex', 'neopredeljen', TRUE);
            ?&gt;
        </p>

        <p>
            &lt;input type="submit" class="greenButton" value="Submit" /&gt;
        </p>
&lt;?php echo form_close(); ?&gt;



My add user in model:
Code:
public function add_user()
{
  $data=array(
   'username'=>$this->input->post('user_name'),
   'email'=>$this->input->post('email_address'),
   'password'=>md5($this->input->post('password')),
            'realname'=>$this->input->post('user_rname'),
            'surname'=>$this->input->post('user_rsname'),
            // how can I add location(dropdown) and sex(radio button) to my database

   );
  $this->db->insert('user',$data);
}

My questions:

1. How can I add location and sex to my database?

2. How can I have whole radio button selection in one line? (now we have 3 radio buttons in 3 lines)

3. How can I add textarea into my form?

I know these are some basic and for most of you a piece of cake. I'd be very gratefully for all answers :$
#2

[eluser]Ivar89[/eluser]
Form Helper User Guide
#3

[eluser]CodeIgniteMe[/eluser]
After you have read the User Guide, you can also check your $_POST array or the array returned by $this->input->post() to see where and what to access for the data you need.




Theme © iAndrew 2016 - Forum software by © MyBB