Abulurd
Abulurd

Reputation: 1066

process form using codeigniter's built in functions

I would like to make form utilizing codeigniter wherein I use the built in functions

$this->input->post();

Upon submitting the form let, I would like for the person to know the number of times this form was submitted. Please, keep in mind, I am new to codeigniter and so I would like a good explanation.

This is the form that I would like to work with.

<html>
<head>
<title>The FORM</title> 
<body>
    <form action="" name="myform" method="post">
      First Name: <input type="text" name="firstname"><br>
      Last Name:  <input type="text" name="lastname"> 
      <input tpe="submit"> 
    </form> 
</body> 
</html>

I will not be storing in database. I also want to use CI Sessions.

Upvotes: 0

Views: 199

Answers (1)

Dan
Dan

Reputation: 9468

You should use form_open() instead of <form>.

You need to put the logic to update sessions in your controller.

In your controller:

$this->load->library('session');

$data = array(
                   'firstname'  => $this->input->post('firstname'),
                   'lastname'     => $this->input->post('lastname'),
               );

$this->session->set_userdata($data);

All of this information is in the Codeigniter documentation. You should really check that out first, it has a lot of good examples.

Codeigniter info on sessions

Codeigniter info on forms

Also you have a typo in your submit button, it says input tpe instead of input type

Upvotes: 1

Related Questions