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:redirect

于 2012-08-13T06:17:57.477 に答える