title: Error in PHP Search
body: <p>This is my PHP code of the "Search Box" I am going to include in my website. I am getting the following error when I try to search my database by entering keywords.</p>
  
  <blockquote>
    <p>Notice: Undefined index: searchterm in C:\xampp\htdocs\abell12\search.php on line 14</p>
  </blockquote>
  
  <p>...And this is the full php code</p>
  
  <p>index.php</p>
  
  <pre><code>    &lt;!doctype html&gt;
      &lt;html&gt;
      &lt;head&gt;
      &lt;meta charset="utf-8"&gt;
      &lt;title&gt;Search (with keywords) Tutorial&lt;/title&gt;
      &lt;/head&gt;
  
      &lt;body&gt;
      &lt;form action="search.php" method="POST"&gt;
          &lt;input type="text" name="searchterm" placeholder="Search..."&gt;&lt;br /&gt;
          &lt;input type="submit" value="Search"&gt;
      &lt;/form&gt;
      &lt;/body&gt;
      &lt;/html&gt;
  </code></pre>
  
  <p>search.php</p>
  
  <pre><code>&lt;!doctype html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta charset="utf-8"&gt;
  &lt;title&gt;Search (with keywords) Tutorial&lt;/title&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  &lt;?php
  
  mysql_connect("127.0.0.1","root","root");
  mysql_select_db("dummy_info");
  
  $search = mysql_real_escape_string($_POST['searchterm']);
  
  $find_books = mysql_query("SELECT * FROM `listings` WHERE `title` LIKE'%$search%'");
  while($row = mysql_fetch_assoc($find_books))
  {
      $title = $row['title'];
  
  
      echo "$title&lt;br /&gt;";
  
  }
  
  ?&gt;
  &lt;/body&gt;
  &lt;/html&gt;  
  </code></pre>