質問

重複の可能性:
「戻る」ボタンでフォームデータを再送信($_POST)

質問を編集するのではなく、新しい質問として置くことを提案する人もいます。そのため、私はそうしています...

<?php
session_start();

if(isset($_POST['username']) && ($_POST['password'])) 
{

                $con=mysql_connect("localhost","root","");
                if(!$con)
                {
                die('Could Not Connect:'.mysql_error());
                } 

                mysql_select_db("tcs",$con);

                $usr=$_POST["username"];                 //pick username from login page
                $pwd=hash('sha1',$_POST['password']);    //pick password from login page and use hash algorithm to encrypt it

                $query="select * from employee where Username='$usr' and Password='$pwd'";  //serch that single row in which both r found
                $result=mysql_query($query,$con);


                    if ($result) 
                    {

                                $row=mysql_fetch_array($result);

                        if (($row["Username"]==$usr) && ($row["Password"]==$pwd))
                        {

                                $_SESSION['employee']['id']=$row['User Id'];
                                $_SESSION['employee']['username']=$row['Username'];
                        }       
                        else
                        {
                                echo "Login Not Successfull";
                        }
                    }   
}

else
{
echo 'Error! Username & Password were not sent!';
}

$_SESSION['user_authenticated'] = true;

?>

<html>
<body bgcolor="black">


<?php 
if($_SESSION['user_authenticated']) 
{


                                echo "<font color=red>"."<h3 align=center>"."Welcome ".$_SESSION['employee']['username']."</h3>"."</font>";
                                echo "<br />"."<a href='upload_file.php'>"."<font color='white'>"."<h4>"."Up-Load Files"."</h4>"."<font>"."</a>";
                                echo "<br />"."<br />"."<a href='list_files.php'>"."<font color='white'>"."<h4>"."List All Up-Loaded Files"."</h4>"."<font>"."</a>";

}



?>

</font>
<a  href="logout_file.php"><font color="white"><h3 align="right">Sign Out</h3></font></a>
<font color="white">

</body>
</html>

OK、これで要点は理解できました。しかし、もう 1 つ問題があります。サインアウトのリンクがあるサインイン アクション ページにいるとします。サインアウト ボタンをクリックすると、サインイン ページにリダイレクトされます。OK問題ありませんが、もう一度戻るボタンを押すと、(サインアウトした後でも) データを再送信するように求められ、またサインインアクションページにいます。なぜそうなるのか。それは間違っています。これを行うのは何ですか。アップロードボタンから[サインアウト]ボタンをクリックした場合など、他のすべてのページ - >サインインにリダイレクトされ、バックボタンを押すとサインアウトされていることが表示されます。署名アクションのセッション変数 exit を確認する方法がわかりません

フェリックス卿が私にこれを確認するように言ったので http://www.thefutureoftheweb.com/blog/get-redirect-after-post

でも、本当にこの人が何を言っているのか理解できません。申し訳ありませんが、私は初心者なので、自分が直面している問題はわかっています...

私の知る限りでは

    if (count($_POST)) {             //checking how many time data is being resend.
        // process the POST data
   add_comment($_POST);        //what this function do i dont know 

   // redirect to the same page without the POST data
header("Location: ".$_SERVER['PHP_SELF']);  //i think it is like  
                                //refreshing without get input again from allpication form
        die;
    }

説明してください、特にこれは何ですか $_server(;PHP_SELF)

正しい解決策はありません

他のヒント

$_SERVERについて - 。こののを参照してください。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top