我的网页上有一个表单,其中'action'指定用于执行查询的php文件。我想按下按钮执行该查询并打开一个名为details.php的新网页。我怎样才能做到这一点?查询工作正常。在执行查询后,它应该打开details.php页面。我的输出打印代码如下所示。谢谢提前
if(move_uploaded_file($_FILES['photo']['tmp_name'], $target))
{
echo "The image has been uploaded, and your information has been added";
}
else {
echo "Sorry, there was a problem uploading your file.";
}
我需要使用主页按钮将此结果打印在网页(页面尺寸与之前数据输入页面相同)
即使同一页面显示结果也没问题,但是应该清除表格中的数据,以便用户可以输入新数据
答案 0 :(得分:1)
以最简单的形式,
if(move_uploaded_file($_FILES['photo']['tmp_name'], $target))
{
$msg = "The image has been uploaded, and your information has been added";
$size = <place the value here>
$filename = <place file name here>
header("Location: details.php?msg={$msg}&size={$size}&fn={$filename}&target={$target}");
exit();
}
else {
echo "Sorry, there was a problem uploading your file.";
}
然后在details.php
$msg = $_GET['msg'];
$size = $_GET['size'];
$fn = $_GET['fn'];
$destination = $_GET['target'];
echo "<p>".$msg."</p>";
echo "<p>File size is: ".$size."</p>";
echo "<p>File name is: ".$fn."</p>";
echo "<p>File uploaded at :".$destination."</p>";
echo "<input type='button' value='Home' onclick='window.location.href=\"home.php\"' />";
PS:不要忘记清理所有数据
答案 1 :(得分:0)
使用header()
只会导航用户当前所在页面到您想要的页面。要创建具有所需尺寸的新弹出窗口,您必须使用JavaScript。
您可以使用AJAX处理请求,并让PHP向客户端JS返回一条消息,以触发新的弹出页面打开。