• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Newbie Help - form submission

Hi all,

I'm VERY new to PHP and CI and learning SLOWLY! I have been through the tutorials and understand how it is working but just can't seem to modify it for my ends:

I would appreciate some advice with structuring my MVC code to do the following:

1) display a form that takes user input.
2) when submitted that input is queried against db to get a result.
3) display the result or lack of (on the same form as step 1) and allow the user to enter and submit new criteria, each time displaying the result on the same form.

I'm having problems with:
- understanding when a particular function is called a Controller - do the public function names have to align with a view name? And that function is only called on a controller when that view is viewed??!?
- understanding the concept of routing - the doco seems a bit slim here.

FACT: Debugging is a nightmare!



P.S. I am using Dreamweaver CS6 & latest CI & latest PHP - not sure DW causing me more trouble than not but have no experience to compare with anything else!

My advise, follow these online courses/tutorials:

The best way to learn is the codeigniter user guide so I would recommend you to follow it point by point and come back with specific question of that, that would be easier for us try to explain you how CI works Wink

1. No, you can call whatever view from whatever controller and they have not necessarily have the same name, and not, you can call whatever controller/method you want from whatever view you are viewing.

2. routing is just the way you can create your own ways to specific controller/methods. An brief example:

Lets say you have this file structure:


and inside myFirstController.php you have a method named myFirstMethod(){ ... } so you call that controller method by adding this URL to your web browser


but you want it appears with names different and looks like this

$route['contr/meth'] = 'myFirstController/myFirstMethod';

And codeigniter will route any "contr/meth" to your "myFirstController/myFirstMethod".

Hope that helps.


@ojcraga: Thanks, your explanation of the routing is excellent.

@royduin: Thanks, part way through those tuts.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.