title: How to insert current data into database on submit button click?
body: <p>Im trying to find a way to insert the current user id and cursuscode into my DB but they way i'm trying is it hasn't been an succes yet. If someone click on the submit button I would like to push it into the database but when i click on the button nothing happens. Thats why i think the query is not right/syntax is wrong or my way of using the post method is wrong.</p>
  
  <pre><code>&lt;?php
  session_start();
  require_once('includes/mysql_config.php');
  
  $id = isset($_SESSION['id']) ? $_SESSION['id'] : header('location: login.php');
  $Cursist = mysqli_query($con, "SELECT id FROM Cursist WHERE id =".$_SESSION['id']) || false;
  if(!$Cursist){
    header('location: login.php');
  }
  require_once('./header.php');
  
  $cursusCode = $_GET['cursusCode'];
  $query = "SELECT * FROM cursus WHERE cursusCode = $cursusCode";
  $result = mysqli_query($con, $query);
  $amount = mysqli_affected_rows($con);
  
  for ($i = 0; $i &lt; $amount; $i++) {
    $cursus = mysqli_fetch_array($result);
  ?&gt;
  
       &lt;?php
        if(isset( $_POST['submit'] )){
          $SQL = "INSERT INTO cursistCode (Cursus_cursusCode, Cursist_id) VALUES ($cursusCode, $Cursist)";
               $result = mysql_query($SQL);
          }?&gt;
  &lt;header&gt;
  &lt;/header&gt;
  
  &lt;?php require_once('./navigation.php'); ?&gt;
  &lt;!-- Post Content --&gt;
  &lt;article&gt;
    &lt;div class="container"&gt;
      &lt;div class="row"&gt;
        &lt;div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1"&gt;
          &lt;div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1"&gt;
            &lt;div class="post-preview"&gt;
                &lt;?php echo $cursus['description'] . "&lt;br /&gt;";?&gt;
            &lt;/div&gt;
          &lt;/div&gt;
        &lt;/div&gt;
                &lt;a href="logout.php"&gt;Logout&lt;/a&gt;
        &lt;form method="post" name="myform"&gt;
          &lt;input type="submit" value="Schrijf je in" name="submit"&gt;
        &lt;/form&gt;
        Cursussoort:
        &lt;?php echo $cursus['type'] . "&lt;br /&gt;";?&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/article&gt;
   &lt;?php } ?&gt;
  &lt;hr&gt;
  &lt;?php require_once('./footer.php'); ?&gt;
  </code></pre>
  
  <p>What is it that im doing wrong since as far I can tell this should be fine. My database structure is like this:</p>
  
  <p>Cursist 
  id (pk) links to Cursist_id in table cursistCode (one to many)</p>
  
  <ul>
  <li>name</li>
  <li>password</li>
  <li>not used info in this query</li>
  </ul>
  
  <p>cursistCode </p>
  
  <ul>
  <li>Cursus_cursusCode</li>
  <li>cursist_id</li>
  </ul>
  
  <p>cursus</p>
  
  <ul>
  <li>id (pk) links to Cursus_cursusCode</li>
  <li>not used info in this query</li>
  </ul>
  
  <p>my guest would be i did something wrong here:</p>
  
  <pre><code>  if(isset( $_POST['submit'] )){
      $SQL = "INSERT INTO cursistCode (Cursus_cursusCode, Cursist_id) VALUES ($cursusCode, $Cursist)";
           $result = mysql_query($SQL);
      }?&gt;
  </code></pre>
  
  <p>I hope this will be enough information to help me out if i missed some crical info tell me.</p>