![]() |
Submit button doesn't go to intended route - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Submit button doesn't go to intended route (/showthread.php?tid=50519) |
Submit button doesn't go to intended route - El Forum - 03-28-2012 [eluser]ethereal1m[/eluser] Dear all, I'm following CI tutorial on creating "News" page. I got problem when submit button in creating news is pushed, it doesn't bring execute create page controller but instead it executes view page controller. I suspect the problem lies on the router. Here is the route configuration: Code: $route['news/create'] = 'news/create'; The create news view: Code: <h2>Create a news item</h2> Here is the controller, when submit is pressed, it supposed to go to "create" function, but instead it goes to "view" function. Code: class News extends CI_Controller { What did I miss? regards, ethereal1m Submit button doesn't go to intended route - El Forum - 03-28-2012 [eluser]ethereal1m[/eluser] also in $_SERVER['REQUEST_URI'] variable is set to double URL. For some reason the submit button makes URL request into double URL such as: Code: http://localhost/ci/index.php/news/ci/index.php/news/create What makes it behaving like that? Submit button doesn't go to intended route - El Forum - 03-28-2012 [eluser]solid9[/eluser] First of all did you set the config setting properly below? $config['base_url'] = 'http://samplesite.com/'; And used proper .htaccess ? Submit button doesn't go to intended route - El Forum - 03-28-2012 [eluser]ethereal1m[/eluser] my config: Code: $config['base_url'] = 'localhost/ci'; and I'm using proper .htaccess. looks like form_open from view is causing the problem Code: <?php echo form_open('news/create') ?> the problem is gone when I changed the above code with Code: <form method="post" action="http://localhost/ci/index.php/news/create"> I'm using 2.0.3 since 2.1.0 has problem on OCI8 driver.... is this a bug in form_open procedure? Submit button doesn't go to intended route - El Forum - 03-28-2012 [eluser]solid9[/eluser] try changing from this Code: <input type="submit" name="submit" value="Create news item" /> to this, Code: <?php echo form_submit('submit', 'Create news item'); ?> Submit button doesn't go to intended route - El Forum - 03-28-2012 [eluser]solid9[/eluser] also change from this, Code: </form> to this, Code: <?php Submit button doesn't go to intended route - El Forum - 03-29-2012 [eluser]InsiteFX[/eluser] You also need to add an ending slash on to your base_url! Submit button doesn't go to intended route - El Forum - 03-29-2012 [eluser]ethereal1m[/eluser] nope, I changed my view to Code: <h2>Create a news item</h2> Submit button doesn't go to intended route - El Forum - 03-29-2012 [eluser]ethereal1m[/eluser] With the above code and change this Code: <?php echo form_open('news/create') ?> to Code: <form method="post" action="http://localhost/ci/index.php/news/create"> fixes this.... Submit button doesn't go to intended route - El Forum - 03-29-2012 [eluser]solid9[/eluser] That's fine, but you are not following CodeIgniter standard. The advantage of using the codes below, Code: <?php echo form_open('news/create') ?> Is portability. |