title: Spanning PHP files but method wont echo variables
body: <p>This is a college assignment, so I know you wouldn't do this because it would be too easy to hack. I have searched so hard on this website too and I'm at a dead end. So here it is I have multiple PHP files where I am trying to pull variables across and print out hard coded user information. But my last login in function throws an error no matter what i change i keep getting different errors.This has to be done primarily with PHP and avoiding using SESSION. Any help or direction is appreciated.
  My index form is straight forward.</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta charset="utf-8"&gt;
  &lt;title&gt;sample&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;style&gt;
  &lt;/style&gt;
  &lt;form action="method.php"; method="POST"&gt;
  Name&lt;input type="text" name="userName"&gt;
  Password&lt;input type="text" name="password"&gt;
  &lt;input type="submit" value="Login"&gt;
  &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>my method.php is straight forward too and works.</p>
  
  <pre><code>&lt;?php # person
  
  $name1= $_POST['userName'];
  $password=$_POST['password'];
  //echo 'testclass.php#' . $name;
  
  include 'testclass.php';
  
  ?&gt;
  </code></pre>
  
  <p>But my method credentials won't work in this, it won't find name1 or password?</p>
  
  <pre><code>&lt;?php
  
  class UserController {
  //private $name1;
  //private $password;
  private $isLoggedIn = false;
  
  // Credentials
  public function credentials() {
      $credentials = array(
          array(
              "username" =&gt; "Goat",
              "password" =&gt; "1234"
          ),
          array(
              "username" =&gt; "Goat",
              "password" =&gt; "1234"
          )
      );
      return $credentials;
  }
  
  // Basic login
  public function login() {
      foreach ($this-&gt;credentials() as $credential) {
          //not finding name 1 and password even though its been called in this php file.
          if ($this-&gt;name1 == $credential['username'] &amp;&amp; $this-&gt;password == $credential['password']) {
              $this-&gt;isLoggedIn = true;
          }
      }
  if ($isLoggedIn = true){
      echo "YAYAYA";
  }
  else{
      echo "sad";
  }
  }
  }
  $user = new UserController();
  $user-&gt;credentials();
  $user-&gt;login();
  
  ?&gt;
  </code></pre>
  
  <p>Many thanks.</p>