Manish Sasmal Manish Sasmal - 7 months ago 43
PHP Question

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

contact.html

<html>
<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 -->
</form>




controller : contact.php

<?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.

Answer
<?php
  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 !