简体   繁体   English

提交按钮不会出现

[英]Submit Button won't appear

UPDATE: Here it is my code so far. 更新:这是到目前为止的代码。 The download buttons now appear, but the code is printing the form closing tag instead of identifying it as a closing tag. 现在出现下载按钮,但是代码正在打印表单结束标签,而不是将其标识为结束标签。 How can I correct this? 我该如何纠正? Please help. 请帮忙。 Thanks in advance!! 提前致谢!!

<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";
    }   

}


?>

The report.php files contains the code to generate the excel or pdf file and make it downloadable to the user. report.php文件包含用于生成excel或pdf文件并将其下载给用户的代码。 When running those files by themselves it generates the files just fine. 单独运行这些文件时,它会生成文件。

Change your submit button from: 从以下位置更改您的提交按钮:

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

to

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

The reason behind this is the $_POST variable will only have elements that had a name inside the previous form. 其背后的原因是$ _POST变量将仅包含在先前表单内具有名称的元素。 In your example the submit button does not have a name. 在您的示例中,“提交”按钮没有名称。

It prints /form> because from your codes that's what you asked it to print. 它打印/form>因为您的代码要求您打印它。 You echoed out "/form><br>"; 您回显了"/form><br>"; instead of "</form><br>"; 而不是"</form><br>"; in every line that I can see. 在我所看到的每一行中。 Simply add < to fix that 只需添加<即可解决

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM