php validation is incorrect for drop down menu <p>I have a code below where it displays students details in a drop down menu, and then it does a php validation to see if a student is selected from the drop down menu or not:</p> <pre><code>$sql = "SELECT StudentUsername, StudentForename, StudentSurname FROM Student ORDER BY StudentUsername"; $sqlstmt = $mysqli-&gt;prepare($sql); $sqlstmt-&gt;execute(); $sqlstmt-&gt;bind_result($dbStudentUsername, $dbStudentForename, $dbStudentSurname); $students = array(); // easier if you don't use generic names for data $studentHTML = ""; $studentHTML .= '&lt;select name="students" id="studentsDrop"&gt;'.PHP_EOL; $studentHTML .= '&lt;option value=""&gt;Please Select&lt;/option&gt;'.PHP_EOL; $outputstudent = ""; while($sqlstmt-&gt;fetch()) { $student = $dbStudentUsername; $firstname = $dbStudentForename; $surname = $dbStudentSurname; $studentHTML .= "&lt;option value='" . $student . "'&gt;" . $student . " - " . $firstname . " " . $surname . "&lt;/option&gt;" . PHP_EOL; } $studentHTML .= '&lt;/select&gt;'; $errormsg = (isset($errormsg)) ? $errormsg : ''; if(isset($_POST['resetpass'])) { //get the form data $studentdrop = (isset($_POST['students'])) ? $_POST['students'] : ''; if($studentdrop = "") { $errormsg = "Student is Selected"; } else{ $errormsg = "You must Select a Student"; } } </code></pre> <p>The problem I have though is that even though I have selected a student from the drop down menu, it still displays a message stating that "You Must select a Student".</p> <p>What is suppose to happen is that if the user has not selected a student or in other words when they have submitted the form and the drop down menu is still on the "Please Select" option, then it displays the message stating that user must select a student, else if the user does select a student from the drop down menu then display the message that a student has been selected.</p>