title: Cannot send to database
body: <p>I have been trying to make an admin panel. For the settings, I wanted to run all the scripts in one file so it wouldn't make a mess in the folder. However, when I try to add/edit a row it wouldn't let me.</p>
  
  <p>Note: I can fetch all rows form the database without an issue. Also it does not give an error so I can't look at it.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>&lt;? session_start();
  include '../database.php';
  if (!isset($_SESSION['logged'])) {
  header("Location: login.php");
  }
  if ($_GET['action'] == 'add') {
  if (!isset($_POST['submit'])) {
   ?&gt;
  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
      &lt;head&gt;
          &lt;link rel="stylesheet" type="text/css" href="main.css"&gt;
          &lt;link rel="stylesheet" type="text/css" href="../css/menu.css"&gt;
          &lt;link rel="stylesheet" type="text/css" href="../css/atasoy.css"&gt;
          &lt;title&gt;Yönetim Paneli - Berru Perde&lt;/title&gt;
          &lt;meta charset="UTF-8"&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;h1&gt;Add Slide&lt;/h1&gt;
          &lt;br&gt;
          &lt;br&gt;
          &lt;form action="&lt;?=$_SERVER['PHP_SELF']; ?&gt;" method="post" align="center"&gt;
          &lt;label for="name"&gt;Name&lt;/label&gt;&lt;br&gt;&lt;input type="text" name="name"&gt;&lt;br&gt;
          &lt;label for="link"&gt;Image Link (&lt;a href="javascript:void(0);" onclick="window.open('upload1.php', 'Image Upload', 'width=400, height=200');"&gt;Upload Image&lt;/a&gt;)&lt;/label&gt;&lt;br&gt;
          &lt;input name="link"&gt;&lt;br&gt;&lt;input type="submit" name="submit" value="Add Image"&gt;
          &lt;/form&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  &lt;?
  } else {
      $name = $_POST['name'];
      $link = $_POST['link'];
  
      $query = $mysqli-&gt;query("INSERT INTO `carousel` VALUES ('', '$name', '$link')");
  
      header("Location: carousel.php");
  }
  } elseif ($_GET['action'] == 'edit') {
      $id = $_GET['id'];
      $result = $mysqli-&gt;query("SELECT * FROM `carousel` WHERE `id` = '$id'");
      $fetch = $result-&gt;fetch_array();
      if (!isset($_POST['submit'])) {
   ?&gt;
  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
      &lt;head&gt;
          &lt;link rel="stylesheet" type="text/css" href="main.css"&gt;
          &lt;link rel="stylesheet" type="text/css" href="../css/menu.css"&gt;
          &lt;link rel="stylesheet" type="text/css" href="../css/atasoy.css"&gt;
          &lt;title&gt;Admin Panel&lt;/title&gt;
          &lt;meta charset="UTF-8"&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;h1&gt;Edit Slide&lt;/h1&gt;
          &lt;br&gt;
          &lt;br&gt;
          &lt;form action="&lt;?=$_SERVER['PHP_SELF']; ?&gt;" method="post" align="center"&gt;
          &lt;label for="name"&gt;Name&lt;/label&gt;&lt;br&gt;&lt;input type="text" name="name" value="&lt;?=$fetch['name']; ?&gt;"&gt;&lt;br&gt;
          &lt;label for="link"&gt;Image Link(&lt;a href="javascript:void(0);" onclick="window.open('upload1.php', 'Image Upload', 'width=400, height=200');"&gt;Upload Image&lt;/a&gt;)&lt;/label&gt;&lt;br&gt;
          &lt;input name="link" value="&lt;?=$fetch['link']; ?&gt;"&gt;&lt;br&gt;&lt;input type="submit" name="submit" value="Save"&gt;
          &lt;/form&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  &lt;?
  } else {
      $id = $_GET['id'];
      $name = $_POST['name'];
      $link = $_POST['link'];
  
      $mysqli-&gt;query("UPDATE `carousel` SET `name`='$name', `link`='$link' WHERE `id`='$id'");
      header("Location: carousel.php");
  } # Delete script not done yet
  } else {
  ?&gt;
  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
      &lt;head&gt;
          &lt;link rel="stylesheet" type="text/css" href="main.css"&gt;
          &lt;link rel="stylesheet" type="text/css" href="../css/menu.css"&gt;
          &lt;link rel="stylesheet" type="text/css" href="../css/atasoy.css"&gt;
          &lt;title&gt;Admin Panel&lt;/title&gt;
          &lt;meta charset="UTF-8"&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;h1&gt;Slideshow Editor&lt;/h1&gt;
          &lt;br&gt;
          &lt;br&gt;
          &lt;ul class="addthings"&gt;&lt;a href="carousel.php?action=add"&gt;&lt;li&gt;&lt;img src="http://www.widgetop.com/images/AddWidgets.png"&gt;Yeni Carousel Slaytı Ekle&lt;/li&gt;&lt;/a&gt;&lt;/ul&gt;
          &lt;table class="listing" align="center"&gt;
              &lt;tr&gt;
                  &lt;td class="darkblue"&gt;ID&lt;/td&gt;
                  &lt;td class="darkblue"&gt;Name&lt;/td&gt;
                  &lt;td class="darkblue"&gt;Preview&lt;/td&gt;
                  &lt;td class="darkblue"&gt;Edit&lt;/td&gt;
                  &lt;td class="darkblue"&gt;Delete&lt;/td&gt;
              &lt;/tr&gt;
              &lt;?
              $query = $mysqli-&gt;query("SELECT * FROM `carousel` ORDER BY `id`");
              while ($fetch = $query-&gt;fetch_array()) {
              $i = $fetch['id'];
              if ($i % 2 != 0) {
              echo "&lt;tr class='lightblue'&gt;&lt;td&gt;" . $fetch['id'] . "&lt;/td&gt;";
              echo "&lt;td&gt;" . $fetch['name'] . "&lt;/td&gt;";
              echo "&lt;td&gt;&lt;img src='" . $fetch['link'] . "' width='117.5' height='67.5'&gt;&lt;/td&gt;";
              echo "&lt;td&gt;&lt;a href='carousel.php?action=edit&amp;id=" . $fetch['id'] . "'&gt;&lt;img src='http://docs.gimp.org/en/images/dialogs/stock-edit-16.png'&gt;&lt;/a&gt;&lt;/td&gt;";
              echo "&lt;td&gt;&lt;a href='carousel.php?action=delete&amp;id=" . $fetch['id'] . "'&gt;&lt;img src='https://cdn2.iconfinder.com/data/icons/aspneticons_v1.0_Nov2006/delete_16x16.gif'&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;";
              } else {
              echo "&lt;tr class='white'&gt;&lt;td&gt;" . $fetch['id'] . "&lt;/td&gt;";
              echo "&lt;td&gt;" . $fetch['name'] . "&lt;/td&gt;";
              echo "&lt;td&gt;&lt;img src='" . $fetch['link'] . "' width='117.5' height='67.5'&gt;&lt;/td&gt;";
              echo "&lt;td&gt;&lt;a href='carousel.php?action=edit&amp;id=" . $fetch['id'] . "'&gt;&lt;img src='http://docs.gimp.org/en/images/dialogs/stock-edit-16.png'&gt;&lt;/a&gt;&lt;/td&gt;";
              echo "&lt;td&gt;&lt;a href='carousel.php?action=delete&amp;id=" . $fetch['id'] . "'&gt;&lt;img src='https://cdn2.iconfinder.com/data/icons/aspneticons_v1.0_Nov2006/delete_16x16.gif'&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;";
              }
              }
              ?&gt;
          &lt;/table&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  &lt;? } ?&gt;
  </code></pre>
  
  <p>What am I doing wrong?</p>
  
  <p>Any help would be appreciated.</p>