I'm having an issue understanding how to utilize model view controller in the context of my registration system. From my understanding, the view is loaded, showing the user my registration html form. Once the user hits submit, I have a javascript registration class that uses ajax to handle the POST of the data the user entered. My main index.php file has the usual
if(isset($_POST['action'])) {
if($_POST['action'] == "register") {
// send the data to the model
}
}
The model will handle all the database related registration logic, and sends a message back indicating a success or fail. This message is captured by the ajax in my registration javascript class, which updates some of the views HTML to tell the user whether the registration was a success or fail (valid email etc).
My main questions would be why would my view need a reference to the model, like every example i see. And what part of the above registration system is the controller supposed to handle.