title: Post results back to same page as search form
body: <p>I am doing a project and need some help please :)   (full code at bottom)</p>
  
  <p>The project needs to be accessed with PDO.<br>
  I need search results to appear on the same page as the search was entered.</p>
  
  <p>This below doesnt seem right to me using GET instead of POST.. is this correct?
  This works but I need to remove/hide this bit of code that appears when my page (index.php) first loads.</p>
  
  <pre><code>if(!isset($_GET['search']))
  {   echo "Error, Please go back.";  exit;}
  </code></pre>
  
  <p>How do i do that?</p>
  
  <p>Also my second problem is I can not get the search form to search more than one field in a table. It just wont let me. I cant use this bit of code either</p>
  
  <pre><code>%'.$searchterm.'%
  </code></pre>
  
  <p>as it wont give me any feedback from the search. So i am using the </p>
  
  <pre><code>:searchterm
  </code></pre>
  
  <p>in</p>
  
  <pre><code>$searchterm = $_GET['search'];
  $stmt = $conn-&gt;prepare("SELECT * FROM boxer WHERE weightclass LIKE :searchterm OR nationality ");
  $stmt-&gt;bindValue(':searchterm','%'.$searchterm.'%');
  $stmt-&gt;execute();
  </code></pre>
  
  <p>Here is my full code:</p>
  
  <pre><code>&lt;?php
  
  $servername = 'localhost';
  $username = "root";
  $password = "";
  $dbname = "u1360138";
  
  &lt;?php
  if(isset($_POST['search'])){
      echo 'Search';
  }
  ?&gt;
  
  
  &lt;!-- Search facility 1 --&gt;
  &lt;form action="index.php" method="get"&gt;
  &lt;label for="search"&gt;Enter a weight class. Need to be more than one searchs which wont work&lt;/label&gt;
  &lt;input type="text" name="search" id="search"&gt;
  &lt;input type="submit" value="Search"&gt;
  &lt;/form&gt;
  &lt;?php
  // DB Connection
  try {$conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);}
  catch(PDOException $e)
  {echo "Error conntecting to the DB: " . $e-&gt;getMessage();}
  if(!isset($_GET['search']))
  {   echo "Error, Please go back.";  exit;}
  // DB Connection
  
  
  $searchterm = $_GET['search'];
  $stmt = $conn-&gt;prepare("SELECT * FROM boxer WHERE weightclass LIKE :searchterm");
  $stmt-&gt;bindValue(':searchterm','%'.$searchterm.'%');
  $stmt-&gt;execute();
  // loop displays loop
  while ($boxer = $stmt-&gt;fetch(PDO::FETCH_OBJ))
  { echo "&lt;ul&gt;";
  echo "&lt;a href='details.php?idboxer=".$boxer-&gt;idboxer."'&gt;";
  echo "&lt;li&gt;".$boxer-&gt;firstname." ".$boxer-&gt;lastname."&lt;/li&gt;";
  echo "&lt;/a&gt;";
  echo "&lt;/ul&gt;"; }
  $conn=NULL;
  ?&gt;
  </code></pre>