When I try to load the form data in browser it shows this error
{"":"Unknown method"}
HOW TO SOLVE
This is the controller code in REST API using Codeigniter.
Help me to get out from this problem.......
require(APPPATH.'/libraries/REST_Controller.php');
class Api extends REST_Controller{
public function __construct()
{
parent::__construct();
// $this->CI->lang->load('form_validation');
$this->load->model('book_model');
$this->load->helper('url');
}
public function view_get(){
$this->load->helper('form');
}
public function display_post(){
$this->load->helper('form');
$this->load->view('add');
}
}
Add.php code is here, I want to display the data in webpage through the controller but when I run this code it shows an error
{"":"Unknown method"}
url: http://localhost/code-restfullAPI/index.php/API/display
<!DOCTYPE html>
<html>
<body>
<form method="POST" action="<?php site_url('index.php/Api/addBook_post'); ?>">
Name:<br>
<input type="text" name="name" >
<br>
Price:<br>
<input type="text" name="price" >
<br>
Author:<br>
<input type="text" name="author" >
<br>
Category:<br>
<input type="text" name="category" >
<br>
Language:<br>
<input type="text" name="language" >
<br>
ISBN:<br>
<input type="text" name="isbn" >
<br>
Publish Date:<br>
<input type="text" name="publish_date" >
<br>
<input type="submit" value="Add">
</form>
</body>
</html>
display, the request must be aPOSTrequest (you've literally added that, the_postpart) while the browser usesGETto access URL's. - M. ErikssonGETmethod. Rename it todisplay_get()- M. Erikssondisplay_post()and onedisplay_get(). I don't see why you should be able to access it through GET though, since I'm guessing it's handling the form data (which doesn't exist if you go directly to the end point)? I also don't get what your form have to do with anything. - M. Eriksson