title: Trying to send info to my database from a select tag
body: <p>Been trying to get this PHP to send to my database but for some reason it won't work but it isn't giving me any errors either. The code probably isn't the prettiest only been working on PHP for 6 months so any help is much appreciated. </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;form method="POST"&gt;
                      &lt;div class="form-group"&gt;
                          &lt;label for="exampleFormControlSelect1"&gt;Send Message to: &lt;/label&gt;
                          &lt;select class="form-control" id="slectrecipient" name="recipient"&gt;
                             &lt;?php 
                             include("conn.php");
  
                             $info = "SELECT FirstName, SecondName, id FROM PT_accounts WHERE NOT id='$accountid'";
                             $result4 = $conn-&gt;query($info);
                             if(!$result4){
                                 echo $conn-&gt;error;
                             }
                             while($row4 = $result4-&gt;fetch_assoc()){
                                 $recipientfirst = $row4['FirstName'];
                                 $recipientsecond = $row4['SecondName'];
                                 $recipientid = $row4['id'];
  
                                 echo "&lt;option value='$recipientid'&gt; $recipientfirst $recipientsecond&lt;/option&gt;";
                             }
                             
                             if(isset($_POST['messagetext'])){
                                  $currentdate = date("Y-m-d H:i:s");
                                  $messagetext = $_POST['messagetext'];
                                  $recipid = $_POST['recipient'];
                                  
                                  echo $currentdate;
                                  echo $messagetext;
                                  echo $recipid;
                                 $messageinsert = "INSERT INTO PT_Messages (SenderID, RecipientID, Date, Message) 
                                 VALUES ('$accountid', '$recipid', '$currentdate', '$messagetext') ";
  
  
                                 $result5 = $conn-&gt;query($messageinsert);
  
                                 if(!$result5){
                                     echo $conn-&gt;error;
                                 }else{
                                     echo "&lt;p&gt; $messageinsert&lt;/p&gt;";
                                     echo "&lt;p&gt;Message Sent!&lt;/p&gt;";
                                 }
                             }
  
                             ?&gt;
                              
                          &lt;/select&gt;
                      &lt;/div&gt;
                      &lt;div class="form-group"&gt;
                          &lt;label for="exampleFormControlTextarea1"&gt;Message :&lt;/label&gt;
                          &lt;text class="form-control" id="messagetext" rows="3"&gt;&lt;/textarea&gt;
                      &lt;/div&gt;
                      &lt;input type="submit" class="btn btn-primary btn-sm" value="Send"&gt;
                  &lt;/form&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>I know there's two <code>$row</code> and <code>$result</code>s but I've altered these in my actual to be different so I know that's not the issue. I'm unsure if it's the select tag with the option value that isn't written correctly. Or if I have to somehow set the dropdown menu selection as a PHP variable to then be sent to the database?</p>