Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8912751
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T04:17:07+00:00 2026-06-15T04:17:07+00:00

When the user does not select an option from the drop down menu, it

  • 0

When the user does not select an option from the drop down menu, it does not display the error message “Please Select a course”. Can anybody see why it is not displaying the message and see if I am doing the php validation right in order to be able to check if a drop down option has been selected or not?

Below is the code:

 $sql = "SELECT CourseId, CourseNo, CourseName FROM Course ORDER BY CourseNo"; 

 $sqlstmt=$mysqli->prepare($sql);

 $sqlstmt->execute(); 

 $sqlstmt->bind_result($dbCourseId, $dbCourseNo, $dbCourseName);

 $courses = array(); // easier if you don't use generic names for data 

 $courseHTML = "";  
 $courseHTML .= '<select name="courses" id="coursesDrop">'.PHP_EOL; 
 $courseHTML .= '<option value="">Please Select</option>'.PHP_EOL;  

 while($sqlstmt->fetch()) 
 { 
     $courseno = $dbCourseNo;
     $course = $dbCourseId;
     $coursename = $dbCourseName; 
     $courseHTML .= "<option value='".$course."'>" . $courseno . " - " . $coursename . "</option>".PHP_EOL;  
  } 

  $courseHTML .= '</select>'; 

  $submittedCourseId = (isset($_POST['courses'])) ? $_POST['courses'] : '';
  $errormsg = (isset($errormsg)) ? $errormsg : '';

        ?>
    <h1>CREATING A NEW ASSESSMENT</h1>

        <form action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" method="post">
        <table>
        <tr>
        <th>Course: <?php echo $courseHTML; ?><input id="courseSubmit" type="submit" value="Submit" name="submit" /></th>
        </tr>
        <tr>
        <td id="errormsg"><?php echo $errormsg; ?></td>
        </tr>
        </table>
        </form>

        <?php

if (isset($_POST['submit'])) {


$submittedCourseId = $_POST['courses'];

if($submittedCourseId){

?>

//need to do functions here

<?php
 }
 else{
$errormsg = "Please Select a Course";
}
?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T04:17:08+00:00Added an answer on June 15, 2026 at 4:17 am

    $errormsg is being filled AFTER the HTML is being output. Therefore, $errormsg will always be blank at the time it is output.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm sending user data via jQuery to TCPDF, but it does not display any
If user select an option from dropdown it will shown it a textbox but
I have result that I want to display as a drop down menu. The
The user does not want to receive the approval emails in Salesforce. Is there
I want to put validator so that if the user does not put the
I'm having a problem dropping a temporary table. The user account does not have
customers does not want to allow user to use back or forward button. Just
I need to add a user profile variable in java, apparently %userprofile% does not
I've done this before with inputs, why on earth does this not work? http://euroworker.no/user/checkout
How does the Authorize Tag determine if the user is authorized or not? Like

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.