PHP $ _POST收到404错误

时间:2014-05-18 18:33:09

标签: php forms post

我正在尝试练习我的PHP表单交互,我遇到了一些障碍。当我取出月份和日期选择时,此代码工作正常但是当我离开它时,我得到404 Page Not Not Error。

 <?PHP 
 if ($_POST['Submit']){ // if the form was submitted
    echo $_POST['homeTeam'];
    echo $_POST['awayTeam'];
    echo $_POST['matchDate'] . ' ';
    echo $_POST['month'] . ' ';
    echo $_POST['day'] . ', ';
    echo $_POST['year'];
  }
 else { //if the form hasn't been submitted yet
 ?>
 <form action="" method="post" id="addMatch">
 <label id="homeTeam">Home: <input type="text" name="homeTeam" /></label> 
 <label id="awayTeam">Away: <input type="text" name="awayTeam" /></label>

 <label id="month">Month:
 <select name="month">
    <?php foreach(range(1,12) as $month){ 
      echo '<option value="' . $month . '">' . date("F",strtotime("0000-$month")) . '</option>';
    }
    ?>
 </select></label>


 <label id="day">Day:
 <select name="day">
    <?php foreach(range(1,31) as $day){
       echo '<option value="' . $day . '">' . $day . '</option>';
    }
    ?>
 </select></label> 


 <input type="hidden" name="year" value="2014" />
 <input type="submit" name="Submit" />
 </form> 
 <?php 
 }
 ?>

我尝试过几种不同的方式重写代码并始终保持相同的结果。

0 个答案:

没有答案