title: Can't submit an input for later use. php
body: <p>I am trying to use a search bar to grab the users input but when i input and submit nothing happens, I its not submitting properly but i can't for the life of me find my mistake. I have copied the input code from a previously created login page which works fine and therefore baffles me even more.</p>
  
  <pre><code>&lt;div class="container"&gt;
          &lt;div class="form-group"&gt;
      &lt;?php
  $stocksymbol = "";
      if ($_SERVER["REQUEST_METHOD"] == "POST") {
  
          if (empty($_POST["stocksymbol"])) {
              $stocksymbolErr = "Please enter Username.";
              } else {
              $stocksymbol = test_input($_POST["stocksymbol"]);
              }
  
          function test_input($data) {
              $data = trim($data);
              $data = stripslashes($data);
              $data = htmlspecialchars($data);
              return $data;
              }}
  
              $servername = "localhost";
              $username2 = "root";
              $password2 = "";
              $dbname = "mydb";
  
              $mysqli = new mysqli($servername, $username2, $password2, $dbname);
  
              if ($mysqli-&gt;connect_error) {
                  die("Connection failed: " . $mysqli-&gt;connect_error);
              } 
               $query = "SELECT * FROM tblstocks WHERE Symbol = '$stocksymbol'";
               if ($result = $mysqli-&gt;query($query)) {
                      while ($row = $result-&gt;fetch_assoc()) {
                      $_SESSION['stockavailable'] = true;
                      $_SESSION['stock']= $row;
                      header('Location: item.php');   
                   }
                   $result-&gt;free();
               } 
              $mysqli-&gt;close();
      ?&gt;
          &lt;form method="post" action="&lt;?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?&gt;"&gt;  
              &lt;label for="stocksymbol"&gt;Search:&lt;/label&gt;
          &lt;input type="text" class="form-control" id="stocksymbol"&gt;
          &lt;br&gt;&lt;br&gt;
              &lt;input type="submit" class="btn btn-default" name="submit" value="Submit"&gt;  
  &lt;/form&gt;
  
  &lt;/div&gt;  
  </code></pre>