更新:ここまでは私のコードです。ダウンロードボタンが表示されますが、コードは終了タグとして識別するのではなく、フォーム終了タグを印刷しています。どうすれば修正できますか?助けてください。前もって感謝します!!送信ボタンが表示されません
<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ファイルを生成し、それがユーザーにダウンロード可能にするコードが含まれています。これらのファイルを単独で実行すると、ファイルが正常に生成されます。
スクリプトのオープン時にエコーを表示しないようにするにはif(isset($ \ _ POST \ ['submit' \]))を使用することができます(http://stackoverflow.com/question/7775512/using-ifisset-postsubmit-to-not-display-echo-when-script-is-open-is-not)( '$ _POSTを使用して送信するための名前を入力する必要があります') – JNevill
ここでコードを更新しました。しかし、今はphpが閉じタグとして識別するのではなく、フォームの終了タグ(/ form>)を出力しています。 –
これは、 'if'文が正しく動作しているという素晴らしいニュースです。 '/ form>'の問題はあなたのhtmlに '<'がないためです。 'echo"/form>
";'は 'echo"であるべきです
";' – JNevill