html dropdown form post to php

11,798

Form elements require a NAME attribute in order to be posted. You have an ID instead.

Share:
11,798
bc rusty
Author by

bc rusty

Updated on June 04, 2022

Comments

  • bc rusty
    bc rusty almost 2 years

    I have a strange error with my form. I always get a Daily selection with a date of 01 Jan 2000. The code for the form is this:

    <!DOCTYPE html>
    <html>
      <body>
        <form name="mainForm" action="ReportForm.php" method="post">
          How Often to Generate Report: 
          <select id="period" onchange="Change(this);">
            <option selected="selected" value="0">Daily</option>
            <option value="1">Weekly</option>
            <option value="2">Monthly</option>
          </select>
    
          <br />
    
          <input type="submit" title="Submit"/>
        </form>
      </body>
    </html>
    

    There are 3 more dropdowns like this for month, day, and year. I might have guessed that the selected="selected" had something to do with it, but the year 2000 is not an option. The default values for theses are January, 1, and 2012. I am thoroughly confused by this, and would appreciate any help.

    The PHP associated with this is:

    <?php
      require "Search.php";
      require "Schedule.php";
    
      Schedule( $_POST['period'],
                      mktime(23, 59, 59, $_POST['month'],
                             $_POST['day'], $_POST['year']) );
    
      Search( "param1", "param2", "param3", "[email protected]" );
    
      exit();
    ?>
    

    Thanks,

    -rusty

    • Matt
      Matt almost 12 years
      Your code doesn't show inputs for 'month', 'day' or 'year'.
  • octern
    octern almost 12 years
    Sounds like this is the answer. The date you're getting is probably the result of one or more of your dynamic mktime parameters being blank.
  • bc rusty
    bc rusty almost 12 years
    Well, credit lack of knowledge for my mistake... Thanks very much. If I could, I'd upvote, but I'm new here
  • Diodeus - James MacFarlane
    Diodeus - James MacFarlane almost 12 years
    You're welcome. That's what the site is here for. Sometimes you just need a fresh set of eyeballs.