0

我的网页中有一个表单,其中“操作”指定了一个 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.";
}

我需要将此结果打印在带有主页按钮的网页中(页面尺寸与之前的数据输入页面相同)

同一个页面显示结果也可以,但是需要清除form中的数据,以便用户输入新数据

4

2 回答 2

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:不要忘记清理所有数据

于 2012-12-04T05:49:49.580 回答
0

usingheader()只会将用户当前所在的页面导航到您想要的页面。为了创建具有所需尺寸的新弹出窗口,您必须使用 JavaScript。

您可以使用 AJAX 处理请求并让 PHP 向客户端 JS 返回消息以触发新的弹出页面打开。

于 2012-12-04T05:39:33.193 回答