0

登録用の index.php と、登録ハンドラとしての login.php があります。登録が失敗すると、エラー メッセージがクライアントに送信されます。このコードを使用してメッセージを送信します

header('Location: http://localhost/musicshare/index.php?reg=false');

そしてindex.phpで受け取ります

if(isset($_POST['reg'])){
        echo 'set';//for checking whether reg is set
        if($_POST['reg']=='false'){
            echo '<script type="text/javascript">';
            echo 'alert("Reg faile")';
            echo '</script>';
        }
    }

ただし、まったく機能していないようです。助けてください、ありがとう。

4

2 に答える 2

1

$_GETの代わりに使用$_POST:

if (isset($_GET['reg']) && $_GET['reg'] == 'false'){
   // do something
}
于 2012-06-15T06:07:25.683 に答える
0

header() を使用すると、GETリクエストが発生します。

したがって、 $_GET['reg'] を使用する必要があります

if(isset($_GET['reg'])){
    echo 'set';//for checking whether reg is set
    if($_GET['reg']=='false'){
        echo '<script type="text/javascript">';
        echo 'alert("Reg faile")';
        echo '</script>';
    }
}
于 2012-06-15T06:07:32.633 に答える