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

  • Home
  • SEARCH
  • 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 9228999
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T05:27:54+00:00 2026-06-18T05:27:54+00:00

Basically, my form will POST to itself upon submit however, I would want the

  • 0

Basically, my form will POST to itself upon submit however, I would want the users’ selected values to remain in case of any error output.

I know how to do this for most form elements however, I’m stumped when it comes to using select.

Here’s my current solution, I’m looking for something more elegant, help?

 <select name="birthday_month" id="dob_month" label="Month" class="" >
  <option value="-1">M</option>
  <option value="1" <?php if(isset($_POST['birthday_month']) && 1 == $_POST['birthday_month']){ echo "selected='selected'";} ?>>Jan</option>
  <option value="2" <?php if(isset($_POST['birthday_month']) && 2 == $_POST['birthday_month']){ echo "selected='selected'";} ?>>Feb</option>
  <option value="3" <?php if(isset($_POST['birthday_month']) && 3 == $_POST['birthday_month']){ echo "selected='selected'";} ?>>Mar</option>
  <option value="4" <?php if(isset($_POST['birthday_month']) && 4 == $_POST['birthday_month']){ echo "selected='selected'";} ?>>Apr</option>
  <option value="5" <?php if(isset($_POST['birthday_month']) && 5 == $_POST['birthday_month']){ echo "selected='selected'";} ?>>May</option>
  <option value="6" <?php if(isset($_POST['birthday_month']) && 6 == $_POST['birthday_month']){ echo "selected='selected'";} ?>>Jun</option>
   <option value="7" <?php if(isset($_POST['birthday_month']) && 7 == $_POST['birthday_month']){ echo "selected='selected'";} ?>>Jul</option>
   <option value="8" <?php if(isset($_POST['birthday_month']) && 8 == $_POST['birthday_month']){ echo "selected='selected'";} ?>>Aug</option>
   <option value="9" <?php if(isset($_POST['birthday_month']) && 9 == $_POST['birthday_month']){ echo "selected='selected'";} ?>>Sep</option>
   <option value="10" <?php if(isset($_POST['birthday_month']) && 10 == $_POST['birthday_month']){ echo "selected='selected'";} ?>>Oct</option>
   <option value="11" <?php if(isset($_POST['birthday_month']) && 11 == $_POST['birthday_month']){ echo "selected='selected'";} ?>>Nov</option>
   <option value="12" <?php if(isset($_POST['birthday_month']) && 12 == $_POST['birthday_month']){ echo "selected='selected'";} ?>>Dec</option>
      </select>
  • 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-18T05:27:56+00:00Added an answer on June 18, 2026 at 5:27 am

    Use a loop to create your <option>s.

    Day

    for ($i=1;$i<=31;$i++) {
      echo "<option value='$i'";
      if ($_POST['birthday_day'] == $i) {
        echo " selected='selected'";
      }
      echo ">$i</option>";
    }
    

    Month

    for ($i=1;$i<=12;$i++) {
      echo "<option value='$i'";
      if ($_POST['birthday_month'] == $i) {
        echo " selected='selected'";
      }
      echo ">".date("M",mktime(0, 0, 0, $i, 1))."</option>";
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically my form will have to add credits to the registered users that was
Basically i have a form where a studentID is inputted, i then want to
Basically, I want to insert rows in the form InventJournalTransfer. I added a menuitem
I've got a simple example here. Basically a form which when submitted will reload
I'm trying to to make a form that will submit a new record and
Is there a way to do the above? Basically, I don't want the form
Basically I am working on a review form in which users fill out items
Bit of a badly written question, but basically I have a Form for users
Basically I want my multi-part form's controller to have a single function that gives
I have a report that is basically a form with multiple empty fields and

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.