Welcome Guest, Not a member yet? Register   Sign In
Using HTTP verbs in routes
#1

Hi all! I have a problem with HTTP verbs in routes.
My config
PHP Code:
$route['test']['POST'] = 'welcome/test'
My controller
PHP Code:
<?php
defined
('BASEPATH') OR exit('No direct script access allowed');

class 
Welcome extends CI_Controller {
    
    public function 
test()
    {
        
$this->load->helper('url');
        
log_message('info''Post value: '.$this->input->post('val'));
        
redirect('/');
    }

My logs
Code:
INFO - 2015-05-22 11:53:31 --> Config Class Initialized
INFO - 2015-05-22 11:53:31 --> Hooks Class Initialized
DEBUG - 2015-05-22 11:53:31 --> UTF-8 Support Enabled
INFO - 2015-05-22 11:53:31 --> Utf8 Class Initialized
INFO - 2015-05-22 11:53:31 --> URI Class Initialized
INFO - 2015-05-22 11:53:31 --> Router Class Initialized
INFO - 2015-05-22 11:53:31 --> Output Class Initialized
INFO - 2015-05-22 11:53:31 --> Security Class Initialized
DEBUG - 2015-05-22 11:53:31 --> Global POST, GET and COOKIE data sanitized
INFO - 2015-05-22 11:53:31 --> Input Class Initialized
INFO - 2015-05-22 11:53:31 --> Language Class Initialized
ERROR - 2015-05-22 11:53:31 --> 404 Page Not Found: Test/index

Why CI try to use Test/index Controller/method?

Where is my mistake?
Reply
#2

I'd guess you're accessing the page via GET instead of POST.
Reply
#3

(This post was last modified: 05-22-2015, 11:29 AM by Sky.)

(05-22-2015, 05:31 AM)Narf Wrote: I'd guess you're accessing the page via GET instead of POST.

I have the same result

PHP Code:
$route['test']['GET'] = 'welcome/test'

Code:
<form action="/test" method="get">
    <input type="text" name="val"/>
    <input type="submit" value="Send"/>
</form>
Reply




Theme © iAndrew 2016 - Forum software by © MyBB