将表单数据提交到 php 文件,但在不同的页面上查看相同的结果


Submit form data to php file but view same results on different page

我正在尝试将表单数据发送到php文件进行处理 - 但我需要在用户点击提交后加载的单独页面上显示相同的信息。

我正在尝试创建一个条形码扫描搜索工具。 用户将条形码扫描到文本框中,然后提交数据以查询 sql 服务器。 我正在使用PDO查询,该站点是内部的,该工具只能由4个人访问 - 所以我不担心SQL注入。 它并不是那么复杂的工具,但是使用这种智能模板的东西非常痛苦。

我不能简单地将嵌套的 php 代码放在同一个页面上,因为该网站正在使用这个 Smarty 模板引擎。

基本上,我的php处理文件在一个插件中被调用,该插件在results.tpl页面上被调用。

results.php->results.tpl->function.scanplugin->php_processing_file(handler.php)

我要么收到未知错误,要么提交按钮什么也没做。 我可以提供更多细节,我只是想保持简短......

下面的 Scan.tpl 文件是用户扫描并提交条形码的地方。

有什么想法吗?

{include file='globalheader.tpl'}
<h1>Barcode Scanning Tool</h1>
<script type="text/javascript">
function resultsview() {
window.location = "results.php";
return false;
}
</script>
<div id="help">
<h3>Scan a barcode and hit SUBMIT</h3>
<br /><br />
<form action="handler.php" onsubmit="return resultsview()" method="post">
<input type="number" name="barcode" value="1" />
<input type="submit" value="Submit" name="submit" />
</form >
</div>
 {include file='globalfooter.tpl'}

我想,从你的代码来看,后数据无处发送,因为 js 获取操作并且只将其重定向到结果.php没有发布数据。我认为您必须将其从处理程序.php重定向。对不起,我的英语不好: