title: Click on button doesn't insert value in database PHP
body: <p>I'm trying to figure out how to insert a value in my database with PHP.
  I'm a student, so I'm pretty new with PHP but I have been struggling with this for the past hours. I'm trying to insert a value in my database 'ic_likes' when I press on a image (that's within a button). </p>
  
  <p>It's telling me this <strong>error</strong> but I'm not really sure what to do with it. I've been looking for it but can't seem to find what I'm doing wrong<br></p>
  
  <blockquote>
    <p>Notice: Undefined index: action in /Applications/MAMP/htdocs/back-end/Development/collection.php on line 56*</p>
  </blockquote>
  
  <p>My database looks like this:</p>
  
  <p><strong>ic:</strong></p>
  
  <pre><code>=======================
         ic_items
  =======================
  id | items | text |url
  =======================
  
  ==============
     ic_likes
  ==============
  id | items_id 
  ==============
  </code></pre>
  
  <p><strong>HTML</strong> </p>
  
  <pre><code>&lt;ul&gt;
      &lt;li&gt;
          &lt;form class="" action="collection.php?id=&lt;?php echo($items[0]['id'])?&gt;" method="post"&gt;
              &lt;input type="hidden" name="action" value="insertLike" /&gt;
              &lt;button type="submit" name="button"&gt;
                  &lt;img src="assets/img/like.svg" alt="Lost love in war" width="20" class="heart"&gt;
              &lt;/button&gt;
          &lt;/form&gt;
          &lt;span class="info-txt aantal"&gt;
  
          &lt;?php
              $aantalLikes = $likesDAO-&gt;getLikesForID($items[0]['id']);
              echo($aantalLikes['total']);
          ?&gt;
  
          &lt;/span&gt; 
      &lt;/li&gt;   
  &lt;/ul&gt;
  </code></pre>
  
  <p><strong>collection.php</strong></p>
  
  <pre><code>foreach ($items as $item) {
      $likes = $likesDAO-&gt;selectByLikeId($item['id']);
  }
  
  if ($_POST['action'] == 'insertLike') {
      $data = array(
          'items_id' =&gt; $item['id']
      );
      $insertedLike = $likesDAO-&gt;insert($data);
      if (empty($insertedLike)) {
          $errors = $likesDAO-&gt;validate($data);
      }
  }
  </code></pre>
  
  <p><strong>likeDAO.php</strong></p>
  
  <pre><code>public function insert($data) {
      $errors = $this-&gt;validate( $data );
      if (empty($errors)) {
          $sql = "INSERT INTO `ic_likes` (`items_id`) VALUES (:items_id)";
          $stmt = $this-&gt;pdo-&gt;prepare($sql);
          $stmt-&gt;bindValue(':items_id', $data['items_id']);
  
          if ($stmt-&gt;execute()) {
              return $this-&gt;selectById($this-&gt;pdo-&gt;lastInsertId());
          }
      }
      return false;
  }
  </code></pre>