title: Incorrect integer value: '' for column 'user_id' at row 1
body: <p>I'm trying to insert into my SQL database. For some reason I'm getting the <code>Incorrect integer value: '' for column 'user_id' at row 1</code> error.</p>
  
  <p>Here's my table schema:</p>
  
  <p><a href="https://i.stack.imgur.com/qdV2h.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qdV2h.png" alt="enter image description here"></a>
  As you can see, <code>user_id</code> is a foreign key that references a column from another table. I'm not sure if you need that information but yeah. I'm getting the error from my insert php.</p>
  
  <p>Here's my insert php:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>&lt;?php
  require_once ('database.php');
  
  if (isset($_POST['send'])) {
  
  $user_id = $_POST['user_id'];
  $full_name = $_POST['full_name'];
  $phone = $_POST['phone'];
  $email = $_POST['email'];
  $fromdate = ($_POST['fromdate']);
  $todate = ($_POST['todate']);
  $reason = ($_POST['reason']);
  $status = ($_POST['status']);
  
  {
  $database-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  $insert_query = "INSERT INTO leaves (user_id, full_name, phone, email, fromdate, todate, reason, status)
  VALUES (?, ?, ?, ?, ?, ?, ?, ?)";
  
  $insert = $database-&gt;prepare($insert_query);
  $insert-&gt;execute(array($user_id, $full_name, $phone, $email, $fromdate, $todate, $reason, $status));
  
  echo "&lt;script&gt;alert('Successfully sent!'); window.location='leaveform.php'&lt;/script&gt;";
  }
  }
  ?&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>Form:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="container"&gt;
      &lt;div class="card"&gt;
          &lt;div class="form__name" style="font-family: Questrial; "&gt;
              Leave Application Form
          &lt;/div&gt;
          &lt;div class="time__container"&gt;
              &lt;div class="section"&gt;
                  &lt;div class="box"&gt;
                      1
                  &lt;/div&gt;&lt;span&gt;Date&lt;/span&gt;
              &lt;/div&gt;
              &lt;form action="insert-leave.php" class="form__time" method="post"&gt;
                  &lt;div class="date"&gt;
                      &lt;label for="date"&gt;From&lt;/label&gt; &lt;input id="date" type="date" name="fromdate" required&gt;
                  &lt;/div&gt;
      &amp;nbsp;
      &amp;nbsp;
      &amp;nbsp;
                  &lt;div class="date"&gt;
                      &lt;label for="date"&gt;To&lt;/label&gt; &lt;input id="date" type="date" name="todate" required&gt;
                  &lt;/div&gt;
                  &lt;div class="timezone"&gt;
                      &lt;label for="timezone"&gt;&lt;/label&gt; 
                          &lt;/select&gt;
                  &lt;/div&gt;
          &lt;/div&gt;
          &lt;div class="message__container"&gt;
              &lt;div class="section"&gt;
                  &lt;div class="box"&gt;
       2
                    
                  &lt;/div&gt;&lt;span&gt;Reason&lt;/span&gt;
              &lt;/div&gt;
              &lt;textarea cols="50" rows="5" name="reason" required&gt;&lt;/textarea&gt;
          &lt;/div&gt;
          &lt;div class="contact__container"&gt;
              &lt;div class="section"&gt;
                  &lt;div class="box"&gt;
       3
                      
                  &lt;/div&gt;&lt;span&gt;Contact Information&lt;/span&gt;
              &lt;/div&gt;
              &lt;div class="form__contact"&gt;
                  &lt;div class="cname"&gt;
                      &lt;label for="cname"&gt;Name&lt;/label&gt; &lt;input name="full_name" type="text" readonly="readonly" value="&lt;?php echo $fullname; ?&gt;" required&gt;
                  &lt;/div&gt;
                  &lt;div class="cnum"&gt;
                      &lt;label for="cnum"&gt;Phone Number&lt;/label&gt; &lt;input id="cnum" type="text" readonly="readonly" name="phone" value="&lt;?php echo $contact; ?&gt;" required&gt;
                  &lt;/div&gt;
                  &lt;div class="email"&gt;
                      &lt;label for="cemail"&gt;Email&lt;/label&gt; &lt;input id="cemail" name="email" readonly="readonly" value="&lt;?php echo $email; ?&gt;" required&gt;
                  &lt;/div&gt;
      &lt;div class="email"&gt;
                      &lt;label for="cemail"&gt;&lt;/label&gt; &lt;input type="hidden" name="status" required&gt;
                  &lt;/div&gt;
      &lt;div class="id"&gt;
                      &lt;label for="id"&gt;&lt;/label&gt; &lt;input type="hidden" name="user_id" required&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
          &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>