1

私はphpプログラミングの初心者で、このコードのどこにエラーがあるのか​​ を見つけることができません:

<p>
       <?php
            function check_input($data)
                {
                    $data = trim($data);
                    $data = stripslashes($data);
                    $data = htmlspecialchars($data);
                    $data = nl2br($data);
                    return $data;
                }
            $password = $_POST['password'];//security check on the input of the password

            if (isset($password))
            {
                if ($password == "hotdog")
                {
       ?>
                    Here is the secret NASA code: <br/>
                    <strong>RT4567EGST442YT3ZQS</strong>
       <?php
                else
                {
       ?>
                    The password is incorrect. <br/>
                    <a href="index.php">go and try here again</a>.
       <?php
                }
                }
            }
            else
            {
       ?>
                You have to put a password. thanks to retry on <a href="index.php">this page</a>.
       <?php
            }
       ?>
   </p> 

どんな助けでも大歓迎です!どうもありがとう。マイク

4

2 に答える 2

2

投稿したコードの 21 行目付近に}. 変化する

    <?php
            else
            {

    ?>

    <?php
            } else
            {
    ?>
于 2012-06-20T00:03:01.503 に答える
1

また、28 行目に追加し}すぎました。

これはうまくいくはずです:

    <p>
   <?php
    function check_input($data)
        {
            $data = trim($data);
            $data = stripslashes($data);
            $data = htmlspecialchars($data);
            $data = nl2br($data);
            return $data;
        }

        $password = $_POST['password'];//security check on the input of the password

        if (isset($password))
        {
            if ($password == "hotdog")
            {
   ?>
                Here is the secret NASA code: <br/>
                <strong>RT4567EGST442YT3ZQS</strong>
   <?php
            }
            else
            {
   ?>
                The password is incorrect. <br/>
                <a href="index.php">go and try here again</a>.
   <?php
            }
        }
        else
        {
   ?>
            You have to put a password. thanks to retry on <a href="index.php">this page</a>.
   <?php
        }
   ?></p> 
于 2012-06-20T00:12:19.323 に答える