CodeIgniter Forums
Why i need to put evrything in a index function - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22)
+--- Thread: Why i need to put evrything in a index function (/showthread.php?tid=41937)



Why i need to put evrything in a index function - El Forum - 05-21-2011

[eluser]Achmed1[/eluser]
Hi all.

I got a question i want to build example a blog or something. Why i can't example put it in a order of functions example one functions validates the form one functions add something to the database. Why i need always to put evrything in a index function is it not possible to do something like this example in order.

Code:
<?php
class Register extends CI_Controller {

    function register()
    {
        Some functions
                
    }

    
    public function index()
    {
        view code here
    }
public function validate()
    {
        validate code here
    }

public function othercode()
    {
        other code
    }
public function here all the functions togetter()
    {
        here all the functions together in one page
    }



  

}
?>



Why i need to put evrything in a index function - El Forum - 05-21-2011

[eluser]darrentaytay[/eluser]
You can make as many functions as you like and call them using:

Code:
$this->validate();
$this->othercode();

etc.


Why i need to put evrything in a index function - El Forum - 05-21-2011

[eluser]Achmed1[/eluser]
[quote author="darrentaytay" date="1306003957"]You can make as many functions as you like and call them using:

Code:
$this->validate();
$this->othercode();

etc.[/quote]

Thanks for the info, But example i got a form with <?php echo form_open('index.php/register/validation'); ?> i need to put all the fucntions in the validation function ?


Why i need to put evrything in a index function - El Forum - 05-21-2011

[eluser]4ever[/eluser]
You can call a function hello by example c:/localhost/ci/site/hello or index function in class site:
c:/localhost/ci/site


Why i need to put evrything in a index function - El Forum - 05-21-2011

[eluser]ramm[/eluser]
[quote author="Achmed1" date="1306004746"]Thanks for the info, But example i got a form with <?php echo form_open('index.php/register/validation'); ?> i need to put all the fucntions in the validation function ?[/quote]

Yes, for that example you will have a controller called "register.php" with a function called "validation".

It is everything here: http://ellislab.com/codeigniter/user-guide/