title: how to store results in more than one variable from a PHP that access a database
body: <p>I'm new to this and I have trouble understanding how all things works. </p>
  
  <p>I have a php/html page and a login form in it. The login submit button executes a php file (let's say check_user.php) in which theoretically it checks the user and password i put in the form in a database. If it finds them I want the php file (check_user.php) to return to the main page the name of the user and his "class" (like supervisor, operator etc) in order to use them for further active change of main page content (like hide/show menus, enable/disbale elements etc). The problem is that the php returns with echo a text as I understand....How can I process this text to be stored in variables (one or more then one) to be usable in the main page? I understand how to pass variables to a php file, but i don't understand how to process the result of the php, except changing the content of an element in the mane page.
  Maybe I need a callback function, I need to use JSON....</p>
  
  <p>PS: I want to do this without $_SESSION</p>
  
  <p>my code is here:</p>
  
  <p>main page: </p>
  
  <pre><code>&lt;div id="show2"&gt;
  
      &lt;?php
          $userErr = $passErr = "";
          $user = $pass = "";
          if ($_SERVER["REQUEST_METHOD"] == "POST") {
              if (empty($_POST["user"])) {
                  $userErr = "User name is required";
              } 
              else {
                  $user = test_input($_POST["user"]);
                  if (!preg_match("/^[a-zA-Z ]*$/",$user)) {
                      $userErr = "Only letters and white space allowed"; 
                  }
              }           
  
              if (empty($_POST["pass"])) {
                  $passErr = "Password is required";
              } 
              else {
                  $pass = test_input($_POST["pass"]);
              }
          }
  
          function test_input($data) {
              $data = trim($data);
              $data = stripslashes($data);
              $data = htmlspecialchars($data);
              return $data;
          }
      ?&gt;
  
      &lt;h2&gt;LOGIN INFORMATION:&lt;/h2&gt;
      &lt;form method="post" action="check_user.php"&gt;  
          User: &lt;input type="text" name="user" value="&lt;?php echo $user;?&gt;"&gt;
          &lt;span class="error"&gt;* &lt;?php echo $userErr;?&gt;&lt;/span&gt;
          &lt;br&gt;&lt;br&gt;
          Password: &lt;input type="password" name="pass" value="&lt;?php echo $pass;?&gt;"&gt;
          &lt;span class="error"&gt;* &lt;?php echo $passErr;?&gt;&lt;/span&gt;
          &lt;br&gt;&lt;br&gt;
          &lt;input type="submit" name="submit" value="Login"&gt;  
      &lt;/form&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>check_user.php:</p>
  
  <pre><code>&lt;?php
  
      if ($_POST["user"] == "xxx" And $_POST["pass"] == "yyyy") { 
          $name = "John Legend";   /*here I assign value from database*/
          $class = "Supervisor";   /*here I assign value from database*/
          echo .... ;   /*here I don't know what to echo. I want to echo $name and $class and use them as variables (not as text) in the main page*/
      }
      else {
          echo "error";
      }
  ?&gt;
  </code></pre>
  
  <p>the implementation for database is not done, but the example still apply to any value I assign to the variables I want the php to echo</p>