drhzn3911 2017-11-06 10:23
浏览 162
已采纳

用php和html显示日期输入

I want to display the value of two inputs with date type but it didn't work. Here is my code,

    <html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <link rel ="stylesheet" href="style_wbr.css"/>
    <title>PORTAIL</title>
</head>
<body>

<br></br>
<br></br>
<br></br>
  <form method = "post" action = "#">
   <div id="date">
  <input type="date" id="date_deb_filtre" name="Date_de_debut" />
  <input type="date" id="date_fin_filtre" name="Date_de_fin" />
</div>
</form>
<br></br>


<form method="post" action='#'>
<div class="test">
  <input type="submit" name="test" id="test" value="test"/>
 </div>
  </form>
 <?php

if(isset($_POST['test']))
    {
       if (! empty($_POST['date_deb_filtre']) and (! 
      empty($_POST['date_fin_filtre'])))
         {

      echo ($_POST['Date_de_debut']);
      echo ($_POST['Date_de_fin']);

          }

        }
    ?>


    </body>
   </html>

When I press the test button, the two dates did not appear on the page, can u guys help me with this

  • 写回答

4条回答 默认 最新

  • douju1280 2017-11-06 10:43
    关注
      <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <link rel ="stylesheet" href="style_wbr.css"/>
        <title>PORTAIL</title>
    </head>
    <body>
    
    <br></br>
    <br></br>
    <br></br>
      <form method = "post" >
       <div id="date">
      <input type="date" id="date_deb_filtre" name="Date_de_debut" />
      <input type="date" id="date_fin_filtre" name="Date_de_fin" />
    </div>
    
    <div class="test">
      <input type="submit" name="test" id="test" value="test"/>
     </div>
      </form>
     <?php
    
    if(isset($_POST['test']))
        {
           if (!empty($_POST['Date_de_debut']) && (!empty($_POST['Date_de_fin'])))
             {
    
          echo $_POST['Date_de_debut'];
          echo $_POST['Date_de_fin'];
    
              }
    
            }
        ?>
    
    
        </body>
       </html>
    

    There are silly mistakes is your code which is like you use two forms for single process and second that you can get value for input field through post method by name not by id.,try using this code this will work.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?