我在一個大型彈出窗口中有一個窗體。我想這樣做:PHP - 使用Magnific Popup在表單提交後顯示消息
1.)用戶提交表單後,將打開一個新的大型彈出窗口,並顯示一條消息,表明它已提交。
2.)例如,如果用戶已經提交了表單,則該大型彈出窗口將顯示消息而不是表單,以防止提交多個報表。
到目前爲止,我有下面的代碼,但它沒有顯示消息。
PHP
if(isset($_POST["btnSubmit"]))
{
$issue = $_POST['issue'];
$sql = "SELECT id, FROM report WHERE id='$id'";
$result = mysqli_query($db, $sql);
$row = mysqli_fetch_array($result, MYSQLI_ASSOC);
if(mysqli_num_rows($result) >= 1)
{
//Show message here
}
else
{
$sql = mysqli_query($db, "INSERT INTO report (id, issue) VALUES ('$id', '$issue')");
}
}
使用Javascript/jQuery的
<script>
function cancel(){
$.magnificPopup.close();
}
$(document).ready(function(){
$('.report').magnificPopup({
type: 'inline',
fixedContentPos: true,
fixedBgPos: true,
overflowY: 'auto',
closeBtnInside: false,
preloader: false,
midClick: true,
mainClass: 'my-mfp-zoom-in',
});
$('#reportSubmittedContainer').magnificPopup({
type: 'inline',
fixedContentPos: true,
fixedBgPos: true,
overflowY: 'auto',
closeBtnInside: false,
preloader: false,
midClick: true,
mainClass: 'my-mfp-zoom-in',
});
});
</script>
HTML
<a href="#reportContainer" class="btnReport report" role="button">
<i class="fa fa-exclamation-triangle"></i> Report
</a>
<div id="reportContainer" class="mfp-hide">
<form class="form-horizontal submitReportForm" role="form" method="POST">
<div class="form-group">
<label class="control-label col-sm-2">Issue:</label>
<div class="col-sm-9">
<textarea id="issue" name="issue" type="text" class="form-control" rows="5"></textarea>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<input type="submit" name="btnSubmit" value="Submit" onclick="return validate();" class="btn btn-default" />
<input type="button" name="btnCancel" value="Cancel" onclick="return cancel();"class="btn btn-default" />
</div>
</div>
</form>
</div>
<div id="reportSubmittedContainer" class="mfp-hide">
We have received your report.
</div>