提交按钮不会出现

时间:2017-01-09 18:37:44

标签: php onsubmit submit-button webclient-download

更新:到目前为止,这是我的代码。现在出现下载按钮,但代码正在打印表单结束标记,而不是将其标识为结束标记。我怎么能纠正这个?请帮忙。在此先感谢!!

<HTML>
<HEAD>
    <meta charset="utf-8">
    <link rel="stylesheet" href="css/style2.css">
    <TITLE>SAE Report</TITLE>
    <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
    <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
  <script>
   $().ready(function() {
     $(".datepicker").datepicker({dateFormat:'yy-mm-dd'});
   });
</script>

</HEAD>
<BODY>
<center>
<h1>SAE Report</h1>
</center>
 <form action = "" method = "post">
 <label>Report Type</label>
    <select id="report" name="report">
        <option value="none"></option>
        <option value="new">New SAEs Report</option>
        <option value="cumulative">Cumulative SAE Report</option>
    </select>
 <label>Start Date</label><input type="text" class="datepicker" name="start">
 <label>End Date</label><input type="text" class="datepicker" name="end">
 <input type="submit" name="submit" value="Submit">
 </form>
</BODY>

 <?php
 $type='';
 $start='';
 $end='';

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

    $type=$_POST['report'];
    $start=$_POST['start'];
    $end=$_POST['end'];

    if ($type=="cumulative"){
        echo "<form action='cumulativeRptExcel.php' method='post' name ='xls'>";
        echo "<input type='submit' name='submitXLS' value='Download Excel'/>";
        echo "/form><br>";
        echo "<form action='cumulativeRptPDF.php' method='post' name ='xls'>";
        echo "<input type='submit' name='submitXLS' value='Download PDF'/>";
        echo "/form><br>";
    }
    elseif($type=='new' and $start!='' and $end!=''){
        echo "<form action='newRptExcel.php' method='post' name ='xls'>";
        echo "<input type='submit' name='submitXLS' value='Download Excel'/>";
        echo "/form><br>";
        echo "<form action='newRptPDF.php' method='post' name ='xls'>";
        echo "<input type='submit' name='submitXLS' value='Download PDF'/>";
        echo "/form><br>";
    }
    elseif($type="new" and ($start=='' or $end=='')){
        echo "You need to select START and END date for the report";
    }   

}


?>

report.php文件包含生成excel或pdf文件的代码,并使其可供用户下载。当自己运行这些文件时,它可以很好地生成文件。

2 个答案:

答案 0 :(得分:0)

从以下位置更改提交按钮:

 <input type="submit" value="Submit">

 <input type="submit" name="submit" value="Submit">

这背后的原因是$ _POST变量只有在前一个表单中有名字的元素。在您的示例中,提交按钮没有名称。

答案 1 :(得分:0)

它会打印/form>,因为您的代码就是您要求它打印的代码。您在我能看到的每一行中都回显了"/form><br>";而不是"</form><br>";。只需添加<即可修复