php - How do I send form data to a CodeIgniter library? -


I have a custom audio library in CodeIgniter and want to send data from the signup form.

I know that I want to send the data to an administrator:

  echo form_open ('login / validate');  

and data is sent to the valid work of the login controller. So how do I send data to a library instead of the controller?

Coordinators do not have libraries. In fact, the way you are asking us to use Used to help

You are actually doing all communication materials inside your controller and then sending your data to the controller is nothing more than one or more PHP classes in its libraries. . Do not break the library work conference.

So if you want to pass the post data in a library function here, it has some example code (changes corresponding to your own application):

  $ this- & Gt; Load-> Library ('example_library'); $ Username = $ this- & gt; Input-> Post ('username'); $ Password = $ this- & gt; Input-> Post ('password'); $ This- & gt; Example_library- & gt; Set_username ($ username); $ This- & gt; Example_library- & gt; Set_password ($ password); $ This- & gt; Example_library- & gt; Set_method ('clean_then_login'); $ This- & gt; Example_library- & gt; Do_login ();  

Basically the above data controller is sent through POST method (from your thoughts form) and then calls some functions from the example library, the user name for login , The password method sets the details and then logs in.

One more easy bit of information is that you can refer to your library how you can refer to the library loading code by doing a small adjustment:

 < Code> $ this- & gt; Load-> Library ('example_library', 'example');  

This allows you to refer to your library, such as the following is too long:

  $ this-> Example- & gt; Set_username ($ username);  

Hope this helps you to understand how you can take the data given to your controller and then send it to any library function or functions.


Comments