post input data to codeigniter controller from outside codeigniter folder

I am facing a problem. I have a normal html files (contact.html) in cpanel's public_html folder. And admin panel which is developed in CodeIgniter. Now what i am trying to do is print or receive input data from contact.html file to codeigniter controller. Below mention the code


  <form name ="userinput" action="admin/index.php/contact/contact" method="post">
  <div class="row contact-form">
  <div class="col-lg-6">
  <input type="text" name="yourname" id="yourname" class="form-control" placeholder="Your Name">
   </div><!-- end col -->
  </div><!-- end row -->

controller : contact.php

class Contact extends CI_Controller
  function contact()
   echo 'test';
   echo $yourname = $this->input->post('yourname');

now when i am submitting data 'test' is printing but i can not get the post data of textbox. The error is mention below.

A PHP Error was encountered

Severity: Notice

Message: Undefined property: Contact::$input

Filename: controllers/contact.php

Line Number: 12

please help me how will i get it.

  class Contact extends CI_Controller
    public function contact(){
    echo 'test';
    echo $yourname = $this->input->post('yourname');
    $this->load->view('index');  // put this file in application/views/index.php  ,also rename to .php

Try creating the function in your controller. Hope it helps !

You need to have a index function or another function

File name: Contact.php file name and class should have only first letter upper case with controllers and models.


class Contact extends CI_Controller {

   public function index() {

   $yourname = $this->input->post('yourname');
   echo $yourname;

   // Since you had named the view file with a .html you need to add .html



If you name your view files with .php instead of a .html


I would autoload theurl helperon autoload.php and would look intoform helper

It's possible that since your function name is same as class name that it's treating it as constructor. Rename your function to something else, update your action link in form and try again.

Better try native PHP way of getting value

echo $_POST['yourname'];

Hope this helps

What Others Are Reading