PHP send input values as parameters in method call
<p>I'm new to PHP, trying to replicate a JavaBeans/JSF assignment...</p>

<p>I need to call a method in class Service that verify user name and password. </p>

<p>I have this php in the top of my index.php:</p>

<pre><code>&lt;?php 
include("Service.php");
$service = new Service();
if($_POST) {
    if (!$service-&gt;checkUser($_POST['name'], $_POST['password'])) {
        $error = "Username and password incorrect";
        echo $error;
    }
}?&gt;
</code></pre>

<p>Mu form action calls it's own document:</p>

<pre><code>&lt;form action="index.php" method="post"&gt;
</code></pre>

<p>I have 2 input fields (name, password) like this:</p>

<p></p>

<p>My Service.php class has the function checkUser. It returns a String:</p>

<pre><code>public function checkUser($name, $password) {
    foreach($this-&gt;users as $user) {
        if ($user-&gt;getName() == $name &amp;&amp; $user-&gt;getPassword() == $password) {
            return "welcome.php";
        }
        else
            return "error.php";
    }
}
</code></pre>

<p>How can I use that String to use as navigation when form is submitted?</p>
