CodeIgniter Forums
Using HTTP verbs in routes - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Using HTTP verbs in routes (/showthread.php?tid=61828)



Using HTTP verbs in routes - Sky - 05-22-2015

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?


RE: Using HTTP verbs in routes - Narf - 05-22-2015

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


RE: Using HTTP verbs in routes - Sky - 05-22-2015

(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>