Submitting form values to controller

前端 未结 2 1078
感情败类
感情败类 2020-12-15 11:41

This should be something really simple but I just can\'t get it.

I\'m learning codeigniter and I have a form with following code


  

        
2条回答
  •  猫巷女王i
    2020-12-15 12:06

    Send your values to a function in your controller

      

    in your controller, make a function called "save_userinput":

    input->post();
          // or just the username:
          $username = $this->input->post("username");
    
          // then do whatever you want with it :)
    
        }
    }
    ?>
    

    Hope that helps. Make sure to check out the CI documentation, it's really good. Any more questions, just ask :)

    EDIT: Figured it out. Use this opening form tag instead:

    
    

    I'm used to not having the index.php there, I remove it by using a .htaccess file (like this one), so I overlooked that. It works here with that small edit in the action attribute.

    Alternatively, you could use the form helper:

    Load it in your controller by using this->load->helper('form') and then use this instead of the HTML tag:

提交回复
热议问题