gpt4 book ai didi

php - 在 php 中自动刷新而不提交任何内容..?

转载 作者:行者123 更新时间:2023-11-29 14:19:48 25 4
gpt4 key购买 nike

需要帮助面临的问题:在来自其他页面的情况下在 php 中自动刷新而不提交任何内容?使用的工具:php、html、mysql。

    <?php
session_start();
ob_start();
include('connect.php');
include('functions.php');
$uid = $_SESSION['user'];
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Nikon</title>
</head>

<body>
<div id="wecome" style=" margin-top: 120px; margin-left: 660px; margin-right: 20px;">
<div id="register_detail" style=" margin-top: 35px; margin-left: 30px;">
<?php
$image=$_POST['image'];
$image1=$_POST['image1'];
//$comments=$_POST['comments'];
$image=($_FILES['image']['name']);
$image1=($_FILES['image1']['name']);

//This is the directory where images will be saved
$target = "images/uploaded/";
$targetx = $target . basename( $_FILES['image']['name']);
//Writes the photo to the server
if(move_uploaded_file($_FILES['image']['tmp_name'], $targetx))
{

//Tells you if its all ok
}
else {
//Gives and error if its not
}

$targetx = $target . basename( $_FILES['image1']['name']);

//Writes the photo to the server
if(move_uploaded_file($_FILES['image1']['tmp_name'], $targetx))
{

//Tells you if its all ok
}
else {
//Gives and error if its not
}
if (!$targetx)
{
///echo '<h1>Copy unsuccessfull!</h1>';
$errors=1;
}
//If no errors registred, print the success message
$uid = $_SESSION['user'];
$sql = "update dealer set image = '$image' ,image1 = '$image1' where id = '$uid'";
$result = mysql_query($sql);
$success =2;
?>
<?php
if($success==2)
{
echo '<meta http-equiv="refresh" content="1; url=thank_u.php">';
}
?><div id="option1" style="width: 354px; height: 185px;">
<img src="images/option_big2.jpg" border="0px" /><br/><br/>
</div>
<form enctype="multipart/form-data" action="option_2.php" method="post">
<div id="option3" style="width: 350px; height: 55px; margin-left: 380px;">
<font style="font-size:12px; color:#666666;">Image 1</font>&nbsp;&nbsp;
<input type="file" id="image" name="image"><br /><br />
<font style="font-size:12px; color:#666666;">Image 2</font>&nbsp;&nbsp;
<input type="file" id="image1" name="image1"><br/>
<div id="font" style="margin-top: 4px;">
<font style="font-size:12px;color:#666666;">( jpg, gif, png files only )</font></div>
</div><br/><br/>
<div id="submit" style="margin-top: 10px; text-align:right; margin-right: 110px;">
<input type= "hidden" name="test" value="2"><input type="submit" value ="Submit">
</div>
</form>
</div>

</th>
</tr>

</table>
</body>
</html>

Please help me in solving it urgently...

最佳答案

您已分配 $success =2直接地。上传内容后分配。我的意思是类似的东西

if(move_uploaded_file() == TRUE)
{
$success=2;
}

并且不要在 <meta> 中使用“刷新” 。您想在表单提交后重定向用户,对吧!那你为什么不使用 header:redirect

关于php - 在 php 中自动刷新而不提交任何内容..?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11928908/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com