using routes in Codeigniter to get to one of two controllers











up vote
0
down vote

favorite












I have two controllers Configure.php and Users.php. In my routes.cfg I have:






$route['default_controller'] = 'Users/login';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;
$route['registration'] = 'registration';
$route['login'] = 'login';
$route['subit_backend']['GET']='subit_backend/register';
$route['save_userinput']='Users/save_userinput';





When a user brings up the website the following page comes up in the browser bar https://www.stantiation.com/sub_crud/Users/login/ which is perfect.



The problem is that if a user has forgotten their password I am having trouble routing them to method where they can create a new one. I have the user send an email to themselves where I have placed a "code" that will allow them to update their password. The email has a link to this form:
https://www.stantiation.com/sub_crud/Users/resetPassword?fp_code=492c8bbd3841xxx8201f3a01d77fd.



I also have a view file called view/Users/resetPassword.php which is form that allows the user to enter a new password. That pops up fine. This is the post method of the form.

When the user presses submit, I get https://www.stantiation.com/sub_crud/Users/save_userinput in the toolbar and a 404 error, because there is no save_userinput.php file. I am trying to get the save_userinput() method in the Users.php controller to run, not save_userinput.php in the view/Users/directory. I agree with the 404 because that file doesn't exist.
How can I specify in a form that I want the method in controller Users, not the file view/Users/save_userinput.php? That is why I put the last $route in but that doesn't seem to help.










share|improve this question




























    up vote
    0
    down vote

    favorite












    I have two controllers Configure.php and Users.php. In my routes.cfg I have:






    $route['default_controller'] = 'Users/login';
    $route['404_override'] = '';
    $route['translate_uri_dashes'] = FALSE;
    $route['registration'] = 'registration';
    $route['login'] = 'login';
    $route['subit_backend']['GET']='subit_backend/register';
    $route['save_userinput']='Users/save_userinput';





    When a user brings up the website the following page comes up in the browser bar https://www.stantiation.com/sub_crud/Users/login/ which is perfect.



    The problem is that if a user has forgotten their password I am having trouble routing them to method where they can create a new one. I have the user send an email to themselves where I have placed a "code" that will allow them to update their password. The email has a link to this form:
    https://www.stantiation.com/sub_crud/Users/resetPassword?fp_code=492c8bbd3841xxx8201f3a01d77fd.



    I also have a view file called view/Users/resetPassword.php which is form that allows the user to enter a new password. That pops up fine. This is the post method of the form.

    When the user presses submit, I get https://www.stantiation.com/sub_crud/Users/save_userinput in the toolbar and a 404 error, because there is no save_userinput.php file. I am trying to get the save_userinput() method in the Users.php controller to run, not save_userinput.php in the view/Users/directory. I agree with the 404 because that file doesn't exist.
    How can I specify in a form that I want the method in controller Users, not the file view/Users/save_userinput.php? That is why I put the last $route in but that doesn't seem to help.










    share|improve this question


























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I have two controllers Configure.php and Users.php. In my routes.cfg I have:






      $route['default_controller'] = 'Users/login';
      $route['404_override'] = '';
      $route['translate_uri_dashes'] = FALSE;
      $route['registration'] = 'registration';
      $route['login'] = 'login';
      $route['subit_backend']['GET']='subit_backend/register';
      $route['save_userinput']='Users/save_userinput';





      When a user brings up the website the following page comes up in the browser bar https://www.stantiation.com/sub_crud/Users/login/ which is perfect.



      The problem is that if a user has forgotten their password I am having trouble routing them to method where they can create a new one. I have the user send an email to themselves where I have placed a "code" that will allow them to update their password. The email has a link to this form:
      https://www.stantiation.com/sub_crud/Users/resetPassword?fp_code=492c8bbd3841xxx8201f3a01d77fd.



      I also have a view file called view/Users/resetPassword.php which is form that allows the user to enter a new password. That pops up fine. This is the post method of the form.

      When the user presses submit, I get https://www.stantiation.com/sub_crud/Users/save_userinput in the toolbar and a 404 error, because there is no save_userinput.php file. I am trying to get the save_userinput() method in the Users.php controller to run, not save_userinput.php in the view/Users/directory. I agree with the 404 because that file doesn't exist.
      How can I specify in a form that I want the method in controller Users, not the file view/Users/save_userinput.php? That is why I put the last $route in but that doesn't seem to help.










      share|improve this question















      I have two controllers Configure.php and Users.php. In my routes.cfg I have:






      $route['default_controller'] = 'Users/login';
      $route['404_override'] = '';
      $route['translate_uri_dashes'] = FALSE;
      $route['registration'] = 'registration';
      $route['login'] = 'login';
      $route['subit_backend']['GET']='subit_backend/register';
      $route['save_userinput']='Users/save_userinput';





      When a user brings up the website the following page comes up in the browser bar https://www.stantiation.com/sub_crud/Users/login/ which is perfect.



      The problem is that if a user has forgotten their password I am having trouble routing them to method where they can create a new one. I have the user send an email to themselves where I have placed a "code" that will allow them to update their password. The email has a link to this form:
      https://www.stantiation.com/sub_crud/Users/resetPassword?fp_code=492c8bbd3841xxx8201f3a01d77fd.



      I also have a view file called view/Users/resetPassword.php which is form that allows the user to enter a new password. That pops up fine. This is the post method of the form.

      When the user presses submit, I get https://www.stantiation.com/sub_crud/Users/save_userinput in the toolbar and a 404 error, because there is no save_userinput.php file. I am trying to get the save_userinput() method in the Users.php controller to run, not save_userinput.php in the view/Users/directory. I agree with the 404 because that file doesn't exist.
      How can I specify in a form that I want the method in controller Users, not the file view/Users/save_userinput.php? That is why I put the last $route in but that doesn't seem to help.






      $route['default_controller'] = 'Users/login';
      $route['404_override'] = '';
      $route['translate_uri_dashes'] = FALSE;
      $route['registration'] = 'registration';
      $route['login'] = 'login';
      $route['subit_backend']['GET']='subit_backend/register';
      $route['save_userinput']='Users/save_userinput';





      $route['default_controller'] = 'Users/login';
      $route['404_override'] = '';
      $route['translate_uri_dashes'] = FALSE;
      $route['registration'] = 'registration';
      $route['login'] = 'login';
      $route['subit_backend']['GET']='subit_backend/register';
      $route['save_userinput']='Users/save_userinput';






      php codeigniter-3






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 10 at 15:07

























      asked Nov 10 at 15:00









      Richard Bernstein

      418




      418
























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote













          It seems that you might be understanding the CodeIgniter URL scheme. Read about it HERE.



          Basically, it boils down to http:doman.tld/controller/function[/var1 ...[/varN]]
          So, after the domain you have multiple segments that are interpreted like so:




          1. The first segment represents the controller that should be invoked.

          2. The second segment represents the class function, or method, that should be called.

          3. The third, and any additional segments, represent any variables that will be passed to the controller.


          So the URL https://www.stantiation.com/sub_crud/Users/save_userinput would go to the controller Users (which appears to be in the folder of /application/controllers/sub_crud) and call the controller method save_userinput. It is not looking for a file named save_userinput.php.



          The 404 could be because the controller is not in a sub-folder or because some other file the controller tries to load, i.e. a "view" file, cannot be found.



          It's hard to offer better advice without seeing the html for the form and knowing exactly how you have your file layout structured.



          (Side note: I avoid putting controllers in sub-folders because it messes with the URL "look" and IMO, in terms of "controllers", it's not that hard to track what-is-what.)



          You really only need routes when you want to override CodeIgniter's segment-based approach to URLs. With that in mind, it appears (based on a general lack of understanding about your app) that the following "routes" don't make sense.



          $route['registration'] = 'registration';
          $route['login'] = 'login';
          $route['subit_backend']['GET']='subit_backend/register';
          $route['save_userinput']='Users/save_userinput';





          share|improve this answer





















            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














             

            draft saved


            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53240199%2fusing-routes-in-codeigniter-to-get-to-one-of-two-controllers%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            0
            down vote













            It seems that you might be understanding the CodeIgniter URL scheme. Read about it HERE.



            Basically, it boils down to http:doman.tld/controller/function[/var1 ...[/varN]]
            So, after the domain you have multiple segments that are interpreted like so:




            1. The first segment represents the controller that should be invoked.

            2. The second segment represents the class function, or method, that should be called.

            3. The third, and any additional segments, represent any variables that will be passed to the controller.


            So the URL https://www.stantiation.com/sub_crud/Users/save_userinput would go to the controller Users (which appears to be in the folder of /application/controllers/sub_crud) and call the controller method save_userinput. It is not looking for a file named save_userinput.php.



            The 404 could be because the controller is not in a sub-folder or because some other file the controller tries to load, i.e. a "view" file, cannot be found.



            It's hard to offer better advice without seeing the html for the form and knowing exactly how you have your file layout structured.



            (Side note: I avoid putting controllers in sub-folders because it messes with the URL "look" and IMO, in terms of "controllers", it's not that hard to track what-is-what.)



            You really only need routes when you want to override CodeIgniter's segment-based approach to URLs. With that in mind, it appears (based on a general lack of understanding about your app) that the following "routes" don't make sense.



            $route['registration'] = 'registration';
            $route['login'] = 'login';
            $route['subit_backend']['GET']='subit_backend/register';
            $route['save_userinput']='Users/save_userinput';





            share|improve this answer

























              up vote
              0
              down vote













              It seems that you might be understanding the CodeIgniter URL scheme. Read about it HERE.



              Basically, it boils down to http:doman.tld/controller/function[/var1 ...[/varN]]
              So, after the domain you have multiple segments that are interpreted like so:




              1. The first segment represents the controller that should be invoked.

              2. The second segment represents the class function, or method, that should be called.

              3. The third, and any additional segments, represent any variables that will be passed to the controller.


              So the URL https://www.stantiation.com/sub_crud/Users/save_userinput would go to the controller Users (which appears to be in the folder of /application/controllers/sub_crud) and call the controller method save_userinput. It is not looking for a file named save_userinput.php.



              The 404 could be because the controller is not in a sub-folder or because some other file the controller tries to load, i.e. a "view" file, cannot be found.



              It's hard to offer better advice without seeing the html for the form and knowing exactly how you have your file layout structured.



              (Side note: I avoid putting controllers in sub-folders because it messes with the URL "look" and IMO, in terms of "controllers", it's not that hard to track what-is-what.)



              You really only need routes when you want to override CodeIgniter's segment-based approach to URLs. With that in mind, it appears (based on a general lack of understanding about your app) that the following "routes" don't make sense.



              $route['registration'] = 'registration';
              $route['login'] = 'login';
              $route['subit_backend']['GET']='subit_backend/register';
              $route['save_userinput']='Users/save_userinput';





              share|improve this answer























                up vote
                0
                down vote










                up vote
                0
                down vote









                It seems that you might be understanding the CodeIgniter URL scheme. Read about it HERE.



                Basically, it boils down to http:doman.tld/controller/function[/var1 ...[/varN]]
                So, after the domain you have multiple segments that are interpreted like so:




                1. The first segment represents the controller that should be invoked.

                2. The second segment represents the class function, or method, that should be called.

                3. The third, and any additional segments, represent any variables that will be passed to the controller.


                So the URL https://www.stantiation.com/sub_crud/Users/save_userinput would go to the controller Users (which appears to be in the folder of /application/controllers/sub_crud) and call the controller method save_userinput. It is not looking for a file named save_userinput.php.



                The 404 could be because the controller is not in a sub-folder or because some other file the controller tries to load, i.e. a "view" file, cannot be found.



                It's hard to offer better advice without seeing the html for the form and knowing exactly how you have your file layout structured.



                (Side note: I avoid putting controllers in sub-folders because it messes with the URL "look" and IMO, in terms of "controllers", it's not that hard to track what-is-what.)



                You really only need routes when you want to override CodeIgniter's segment-based approach to URLs. With that in mind, it appears (based on a general lack of understanding about your app) that the following "routes" don't make sense.



                $route['registration'] = 'registration';
                $route['login'] = 'login';
                $route['subit_backend']['GET']='subit_backend/register';
                $route['save_userinput']='Users/save_userinput';





                share|improve this answer












                It seems that you might be understanding the CodeIgniter URL scheme. Read about it HERE.



                Basically, it boils down to http:doman.tld/controller/function[/var1 ...[/varN]]
                So, after the domain you have multiple segments that are interpreted like so:




                1. The first segment represents the controller that should be invoked.

                2. The second segment represents the class function, or method, that should be called.

                3. The third, and any additional segments, represent any variables that will be passed to the controller.


                So the URL https://www.stantiation.com/sub_crud/Users/save_userinput would go to the controller Users (which appears to be in the folder of /application/controllers/sub_crud) and call the controller method save_userinput. It is not looking for a file named save_userinput.php.



                The 404 could be because the controller is not in a sub-folder or because some other file the controller tries to load, i.e. a "view" file, cannot be found.



                It's hard to offer better advice without seeing the html for the form and knowing exactly how you have your file layout structured.



                (Side note: I avoid putting controllers in sub-folders because it messes with the URL "look" and IMO, in terms of "controllers", it's not that hard to track what-is-what.)



                You really only need routes when you want to override CodeIgniter's segment-based approach to URLs. With that in mind, it appears (based on a general lack of understanding about your app) that the following "routes" don't make sense.



                $route['registration'] = 'registration';
                $route['login'] = 'login';
                $route['subit_backend']['GET']='subit_backend/register';
                $route['save_userinput']='Users/save_userinput';






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 10 at 17:09









                DFriend

                6,1701520




                6,1701520






























                     

                    draft saved


                    draft discarded



















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53240199%2fusing-routes-in-codeigniter-to-get-to-one-of-two-controllers%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    The Sandy Post

                    Danny Elfman

                    Pages that link to "Head v. Amoskeag Manufacturing Co."