0

I have created API for Login using POST method but it give me error GET method is work.

Post data through postman

code of student_login method of contrller Api

class Api extends CI_Controller{

public function student_login() {

    $username=$this->input->post['vUserName'];
    $password=$this->input->post['vPassword'];

    $this->load->model('Api_model');

    $result=$this->Api_model->get_login($username,$password);
    if(!empty($result))
    {
        $response["error"]="true";
        $response["message"]="You have been successfully login";
        echo json_encode(array('result'=>$result));
        die( json_encode($response));
    }
    else
    {
        $response["error"]="false";
        $response["message"]="Invalid Username and Password";
        die(json_encode($response));
    }





}

}

Model :To load the data of table tbl_students

class Api_model extends CI_Model { public function get_login($name,$pass) { //echo $name,$pass; $this->db->select('iStudentID,class,section,vDivision,vGrno'); $this->db->from('tbl_students');

    $this->db->where('vUserName',$name);

    $this->db->where('vPassword',$pass);

   //$this->db->from('tbl_students');
    return $this->db->get()->result_array();

}

}

4
  • How are you posting the form like ajax ? , share the form php code Commented May 12, 2016 at 7:09
  • Posting from postman tool Commented May 12, 2016 at 7:17
  • can you post the postman screenshot Commented May 12, 2016 at 7:25
  • your student login controller code please Commented May 12, 2016 at 7:32

1 Answer 1

0

Your Implementation is right, but you can't check the post method through your browser. Try some other tools like postman.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.