0

需要帮助 面临的问题:在不提交任何内容的情况下自动刷新.. 在来自其他页面的 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...  
4

1 回答 1

1

你已经$success =2直接分配了。上传内容后分配。我的意思是

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

并且不要在<meta>. 您想在表单提交后重定向用户,对!那你为什么不使用header:or redirect

于 2012-08-13T06:17:57.477 回答