title: PHP MVC passing form values to controller and model
body: <p>I'm trying to send POST values to the controller and then pass it to the model in PHP but I'm not sure how to go about doing this.</p>
  
  <p>This part of the controller is to see if the user requests for a view like <code>?action=game</code>. This works.</p>
  
  <p>But I'm trying to modify it to allow <code>$_POST</code> to be sent to it and then to the model. </p>
  
  <pre><code>function __construct()
  {
      if(isset($_GET['action']) &amp;&amp; $_GET['action']!="" )
       {
           $url_view = str_replace("action/","",$_GET['action']);
           if(file_exists("views/" . $url_view . ".php" ))
           {
                  $viewname = $url_view;
                  $this-&gt;get_view($viewname . ".php");
            }
            else
            {
                 $this-&gt;get_view('error.php');
            }
       } 
       else 
       {
           $this-&gt;get_view('home.php');
       }  
  }
  </code></pre>
  
  <p>Here's what I got. In the registration form page, the action of the form is <code>?process=register</code> but it doesn't work.</p>
  
  <pre><code>if(isset($_POST['process']) == 'register)
  {
      $this-&gt;get_view('register.php')
  }
  </code></pre>
  
  <p>Get_view function determines what model to bind with the view</p>
  
  <pre><code>function get_view($view_name)
  {
      $method_name = str_replace(".php","",$view_name);
      if(method_exists($this-&gt;model,$method_name))
      {
         $data = $this-&gt;model-&gt;$method_name();
      } else {
        $data = $this-&gt;model-&gt;no_model();
      }
        $this-&gt;load-&gt;view($view_name,$data);
  }
  </code></pre>