php - 在提交表单时在弹出窗口中打印 php 输出
问题描述
我想在提交 html 表单后在弹出窗口中打印 PHP 的输出。下面是我的代码示例。
<?php
if(isset($_POST['button1']))
{
if("condition match")
{
echo "output1";
}
else
{
echo "output2";
}
}
?>
<form class='n-form' action='#' method='post'>
<div>
<button type='submit' name="button1" class='button'>Submit</button>
<a href="../home.php" class="button">Cancel</a>
</div>
</form>
它应该能够根据 if 条件在弹出窗口中打印回显输出。
期待听到。
解决方案
php中没有弹出窗口,您必须在javascript中执行
<?php
if(!empty($_POST))
{
$text = (isset($_POST['button1'])) ? "output1" : "output2";
echo '<script>alert("' . $text . '")</script>';
}
?>
推荐阅读
- gcc - 暗网制作错误:gcc:找不到命令,Makefile:目标配方失败
- networking - 计算Linux中特定端口转发的流量
- plsql - PLSQL错误:SYS_NC
- python - 决定文本是否与“主题 A”有关 - 使用 Python 进行 NLP
- html - 如何在 *ngFor 中使用 .slice().reverse() 和 | 核心价值?
- java - java.lang.ClassCastException: 类 [我无法转换为类 java.lang.Comparable
- python - Seaborn情节,传说重叠图
- python - fasttext' 在 Windows 10 上没有属性 'train_supervised'
- excel - 如果用户过滤数据,如何在 Excel 中使用 SUMIF?
- swiftui - 如何在 SwiftUI 中使用按钮呈现菜单(不是上下文菜单)?