I am new to PHP and have read about MVC. I currently do not use any frameworks and would like to know how I can transfer data from the controller to the view.
Background:
I understand that I am getting values (from htmlForm1.php) in DoWork.php via _GET. My question is: how to get values (from DoWork.php) in htmlForm2.php?
I was thinking about using a session, but is this the only solution? I do not require this data to be persistent after htmlForm2.php
, , ( ).
. , . .
. ServiceFactory . factory , , .
ServiceFactory
P.S.: . , . , , MVC Web.
P.P.S.: . MVC. - , , . , : , /- .
.
, , .
- MVC MVC - . MVC , , : , , (on ). , HTML (Javascript , ), . HTML- , , , , .
- PHP , (IMHO), . , , :
$view = new View('view/myView.php'); $view->assign('a' => 'b');
extract() vars .
extract()
Your choice comes down to a session, http (post / get), or database.
Most often, your form will send data to the controller, the controller will run the data through this model (s), possibly ending with its saving in the table (s).
Then on the following pages, you call data from your model based on something like user_id stored in the session / cookie.