업데이트 : 여기까지는 지금까지 제 코드입니다. 이제 다운로드 단추가 나타나지만 코드는 태그를 닫는 태그로 식별하는 대신 양식 닫기 태그를 인쇄합니다. 이 문제를 어떻게 해결할 수 있습니까? 도와주세요. 미리 감사드립니다 !! 제출 버튼이 나타나지 않습니다.
<?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 파일
<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>
는 엑셀이나 PDF 파일을 생성하고 사용자에게 다운로드 할 수 있도록하는 코드가 포함되어 있습니다. 이러한 파일을 스스로 실행하면 파일이 제대로 생성됩니다.
<input type="submit" value="Submit">
<input type="submit" name="submit" value="Submit">
이 뒤에 그 이유는 이전의 형태로 내 이름을했다 요소가됩니다 $ _POST 변수
에 :
스크립트가 열려있을 때 [echo ($ \ _ POST \ [ 'submit'\])를 사용하지 않으면 if (isset ($ submit) ')를 사용하면 중복 될 수 있습니다. "(http://stackoverflow.com)/question/7775512/using-ifisset-postsubmit-to-not-display-echo-when-open-is-not) ('$ _POST를 사용하여 제출 입력에 이름을 입력해야한다. ') – JNevill
여기에 코드가 업데이트되었습니다. 하지만 지금은 PHP가 양식을 닫는 태그로 식별하는 대신 닫는 태그 (/ form>)를 인쇄하고 있습니다. –
'if' 문이 제대로 작동한다는 것은 좋은 소식입니다. '/ form>'문제는 html에'<'가 없기 때문입니다. 'echo "/ form>
";''echo "이어야합니다
"; ' – JNevill