title: How can I redirect to another page after submit button pressed?
body: <p>Redirecting is not working, after I pressed my submit button. </p>
  
  <pre><code>&lt;?php    
  if ( !empty($_POST)) {
  $id = $_POST['id'];
  $pdo-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  $sql = "DELETE FROM data  WHERE id = ?";
  $q = $pdo-&gt;prepare($sql);
  $q-&gt;execute(array($id));
  Database::disconnect();
  header("Location: index.php");
  } 
  ?&gt;
  
  &lt;button type="submit"&gt;delete&lt;/button&gt;
  </code></pre>
  
  <p>This is strange, because it actually worked on another page I made. Instead my page is just getting refreshed...</p>