title: Take input from a dropdown form and put it into a database PHP
body: <p>I am trying to send the input from a user on a form to my database and I am not sure why it isn't going. I have the sql going to my database and all the correct IDs are met so I think it should be working but I am missing something. It may be something in the if(isset part of the code but most likely something in the dropdown portion. Any help would be appreciated.</p>
  <pre><code>&lt;?php
      session_start();
      if(!isset($_SESSION[&quot;sess_user&quot;])){
          header(&quot;location:login.php&quot;);
      } else {
      ?&gt;   
  &lt;!doctype html&gt;
  &lt;html&gt;
    &lt;head&gt;
    &lt;link rel=&quot;stylesheet&quot; href=&quot;siteCSS.css&quot;&gt;
      &lt;meta charset=&quot;UTF-8&quot;&gt;
      &lt;title&gt;Recommendations&lt;/title&gt;    
    &lt;/head&gt;
    &lt;body&gt;   
      &lt;div id=&quot;wrapper&quot;&gt;    
      &lt;header&gt;
      &lt;h2&gt;Welcome &lt;?=$_SESSION['sess_user'];?&gt;! &lt;a href=&quot;logout.php&quot;&gt;Click to Logout&lt;/a&gt;&lt;/h2&gt;
          &lt;nav&gt;
              &lt;ul&gt;
                  &lt;li&gt;&lt;a href=&quot;member.php&quot;&gt;Home&lt;/a&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;a href=&quot;committees.php&quot;&gt;Committees&lt;/a&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;a href=&quot;recommendations.php&quot;&gt;Recommendations&lt;/a&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;a href=&quot;voting.php&quot;&gt;Voting&lt;/a&gt;&lt;/li&gt;
              &lt;/ul&gt;
          &lt;/nav&gt;
      &lt;/header&gt;    
      &lt;h1&gt;Recommendations Main Page&lt;/h1&gt;
         &lt;form action = &quot;recommendations.php&quot; method=&quot;POST&quot;&gt;
           &lt;br&gt;
    &lt;br&gt;                 
   &lt;label&gt;Recommendation ID: &lt;/label&gt;         
   &lt;select name=&quot;recommended&quot; required&gt;   
           &lt;?php   
           $conn = new mysqli('localhost', 'root', 'root', 'mydb');    
           if ($conn-&gt;connect_error) {    
             die(&quot;Failed: &quot; . $conn-&gt;connect_error);    
           }
           $UserID = $_SESSION['sess_userID'];    
           $selectsql = &quot;select * from user&quot;;    
           echo '&lt;option value=&quot;&quot; disabled selected&gt;Choose option&lt;/option&gt;';    
           $result = $conn-&gt;query($selectsql);    
           if ($result-&gt;num_rows &gt; 0) {    
             while($row = $result-&gt;fetch_assoc()) {    
               echo '&lt;option value=\&quot;'.$row[&quot;UserID&quot;].'&quot;&gt;'.$row[&quot;UserName&quot;].'&lt;/option&gt;';            
             }    
           }              
           ?&gt;    
           &lt;/select&gt;
    &lt;br&gt;
    &lt;br&gt;    
      &lt;label&gt;Committee ID: &lt;/label&gt;
   &lt;select name=&quot;committee&quot; required&gt;   
           &lt;?php    
           $conn = new mysqli('localhost', 'root', 'root', 'mydb');    
           if ($conn-&gt;connect_error) {    
             die(&quot;Failed: &quot; . $conn-&gt;connect_error);   
           }          
           $selectsql = &quot;select * from committee&quot;;   
           echo '&lt;option value=&quot;&quot; disabled selected&gt;Choose option&lt;/option&gt;';    
           $result = $conn-&gt;query($selectsql);
           if ($result-&gt;num_rows &gt; 0) {
             while($row = $result-&gt;fetch_assoc()) {
               echo '&lt;option value=\&quot;'.$row[&quot;CommitteeID&quot;].'&quot;&gt;'.$row[&quot;CommitteeName&quot;].'&lt;/option&gt;';
             }
           }
           ?&gt;
           &lt;/select&gt;
      &lt;br&gt;
      &lt;br&gt;
      &lt;label&gt;Description (Why they should be recommended):&lt;/label&gt;
      &lt;input type=&quot;text&quot; size = 25 class=&quot;textbox&quot; id=&quot;RecommendationDescription&quot; name=&quot;RecommendationDescription&quot; required&gt;
      &lt;br&gt;
      &lt;br&gt;
      &lt;button type=&quot;submit&quot; name=&quot;submit&quot;&gt;Submit&lt;/button&gt;
    &lt;?php
    if(isset($_POST[&quot;submit&quot;])){
      if(!empty($_POST['RecommendationDescription'])) {
        $recomuser=$_POST['RecommendationID'];
        $recommddesc=$_POST['RecommendationDescription'];
        $recomcommittee=$_POST['CommitteeID'];
        $conn = new mysqli('localhost', 'root', 'root', 'mydb');
        if ($conn-&gt;connect_error) {
          die(&quot;Failed: &quot; . $conn-&gt;connect_error);
        }
          $userID = $_SESSION['sess_userID'];
          $sql=&quot;INSERT INTO mydb.recommendation(RecommendatedID, RecommendationDescription, RecommendationSubmissionDate, UserID, CommitteeID) VALUES('$recomuser', '$recommddesc', CURRENT_TIMESTAMP, '$userID', '$recomcommittee')&quot;;
          $result = $conn-&gt;query($sql);
          if($result){
            echo &quot;Recommendation Successfully Created&quot;;
          } else {
            echo &quot;Failure!&quot;;
          }
      }
    }
    ?&gt;    
  &lt;/form&gt;
    &lt;main&gt;
    &lt;/main&gt;
    &lt;/div&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  &lt;?php
  $variable=$_POST['RecommendationName'];
  echo $variable;
  }
  ?&gt;
  </code></pre>