title: Unable to include connection.php file to reuse the connection to database
body: <p>I'm having some problem to include a connection file to my php page.</p>
  
  <p>I have this connessione.php which receive from login.php the user and password to connect to my db:</p>
  
  <pre><code>&lt;?php   
      $host="localhost";
      $user=$_POST["username"];
      $password= $_POST["password"];
      $database = "Park";
      $lingua=$_POST["lingua"];
      $myconn= new mysqli($host,$user,$password,$database); 
  
      if($myconn-&gt;connect_error){
          Header('Location: login.html');
      }else{
          Header('Location: form.html');
      }
  ?&gt; 
  </code></pre>
  
  <p>This is my form.php that should use the connection.</p>
  
  <pre><code>&lt;?php
      require ('connessione.php');
      $query="SELECT CodicePin from Pin";
      $res=$myconn-&gt;query($query);
      $row=$res-&gt;fetch_array(MYSQLI_NUM);
      print_r($row);
  ?&gt; 
  </code></pre>
  
  <p>The problem is that it is unable to use $myconn established in connessione.php and when I try to login with right user/psw i'll be redirect to login.php.</p>
  
  <p>However if i try to modify connessione.php like this and it execute the query without problem.</p>
  
  <pre><code>&lt;?php   
          $host="localhost";
          $user=$_POST["username"];
          $password= $_POST["password"];
          $database = "Park";
          $lingua=$_POST["lingua"];
          $myconn= new mysqli($host,$user,$password,$database); 
  
          if($myconn-&gt;connect_error){
              Header('Location: login.html');
          }else{
          $query="SELECT CodicePin from Pin";
          $res=$myconn-&gt;query($query);
          $row=$res-&gt;fetch_array(MYSQLI_NUM);
          print_r($row);
          }
      ?&gt; 
  </code></pre>
  
  <p>How i can use the same connection established by connessione.php in other php page?
  Thanks, and sorry about my english :)</p>