Welcome Guest, Not a member yet? Register   Sign In
Newbie Help - form submission
#1

[eluser]Unknown[/eluser]
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!

Cheers,

S

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!

#2

[eluser]royduin[/eluser]
My advise, follow these online courses/tutorials:
http://net.tutsplus.com/sessions/codeign...m-scratch/
https://tutsplus.com/course/codeigniter-essentials/
#3

[eluser]ojcarga[/eluser]
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:

application
-controllers
-myFirstController.php

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

http://www.yoursite.com/myFirstController/myFirstMethod

but you want it appears with names different and looks like this
http://www.yoursite.com/contr/meth

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

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

Hope that helps.

Cheers!
#4

[eluser]Unknown[/eluser]
@ojcraga: Thanks, your explanation of the routing is excellent.

@royduin: Thanks, part way through those tuts.




Theme © iAndrew 2016 - Forum software by © MyBB