亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

PHP ?? ??? ??

PHP ??? ?? ?? ??? ???? ???.

? ???? ??? ??? ???? ?? PHP ?? ???? ?? ??? ?????.


? ?? ??? HTML ???? ?? ?? ??? ???? ????. ??? ??? ??, ??? ??? ????? ? , ?? ??:

Instance

<!DOCTYPE HTML>
 <html>
 <head>
     <meta charset="utf-8">
     <title>PHP.cn</title>
 </head>
 <body>
 <h2>PHP 表單驗證實例</h2>
 <form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"> 
    名字: <input type="text" name="name" value="">
     <br>
     E-mail: <input type="text" name="email" value="">
     <br>
     網址: <input type="text" name="website" value="">
     <br>
     備注: <textarea name="comment" rows="5" cols="40"></textarea>
     <br>
     性別:
     <input type="radio" name="gender"  value="female">女
     <input type="radio" name="gender"  value="male">男
     <br>
     <input type="submit" name="submit" value="提交">
 </form>
 </body>
 </html>

???? ?? ??:

5.png

? ?? ??? ?? ??? ??? ????.

<blockquote id="wnedn"></blockquote>
  •           字段        驗證規(guī)則
        名字必須。 +只能包含字母和空格
        E-mail必須。 + 必須是一個有效的電子郵件地址(包含'@'和'.')
        網址可選。如果存在,它必須包含一個有效的URL
        備注可選。 多行輸入字段(文本域)
    ??
        性別必須。 必須選擇一個
    ??? ?? ??
    ???????. +??? ??? ??? ? ????
    ??? URL????. ?? ?? ??? URL? ???? ???.
    ????? ??

    '??', '???', '????' ??? ??? ?? ????, '??' ??? ??? ?? ??? ?????.

    HTML ??? ??? ????.

    ??: <?? ??= " text" name="name" value="">
    ???: <input type="text" name="email" value="">
    ????: <input type= " text" name="website" value="">
    ??: <textarea name="comment"rows="5" cols="40"></textarea>


    ??? ??

    "??" ??? ??? ?????.

    HTML ??? ??? ????.

    ??:
    <?? ??= " radio" name="gender" value="female">??
    <input type="radio" name="gender" value="??">??


    ?? ??

    HTML ?? ??? ??? ????.

    <form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"])";?>

    ??? ???? ???? ?? method="post" ???? ?????.


    $_SERVER["PHP_SELF"] ??? ??????

    $_SERVER["PHP_SELF"]? ?? ?? ?? ????? ?? ??? ???? ???? ?????.

    ??? $_SERVER["PHP_SELF"]? ?? ???? ???? ?? ?? ???? ??? ??? ????. ??? ???? ???? ?? ????? ?? ??? ??? ?? ? ????.


    htmlspecialchars() ??? ??????

    htmlspecialchars() ??? ?? ??? HTML ???? ?????. ?? < ? >? ?? HTML ??? < ??? ?? ???? HTML ?? JavaScript ??? ??? ???? ??? ???? ?? ??? ? ????(?? ??? ???? ??).

    PHP ?? ??? ?? ?? ?

    $_SERVER["PHP_SELF"] ??? ??? ?? ??? ? ????!

    ????? PHP_SELF? ???? ?? ???? ??? ???? CSS??? ?? XSS(?? ??? ????)? ??? ? ????. ? ?? XSS? ???? ???? ?? ???? ?? ? ???? ????? ? ????? ??? ? ????.

    ?? ??? "test_form.php"?? ???? ??? ?????.

    < ;form method="post" action="<?php echo $_SERVER["PHP_SELF"];?>">

    ?? URL? ???? ?? ?? "test_form.php"? ?????. ? ??? ??? ?? ?????.

    <form method=" post " action="test_form.php">

    ?????.

    ??? ???? ???? ?? ???? ?? ??? ????? ?? ?????.

    http://ipnx.cn/test_form.php/% 22 %3E%3Cscript%3Ealert('hacked')%3C/script%3E


    ? URL? ?? ??? ?? ???? ?????.

    <form method="post" action="test_form.php/"><script>alert('hacked')</script>


    ??? ???? ??? ?????, ?? ??? ???????. ? Javascript ??? ???? ??? ? ?????(????? ?? ??? ???). ?? ??? PHP_SELF ??? ??? ??? ? ??? ???? ??? ????.

    ?? ?? JavaScript ??? <script> ??? ??? ? ????! ??? ?? ??? ???? ?? ??? ????? ? ????. ?? ??? ?? ??? ????? ???? ?? ???? ?? ? ????.


    $_SERVER["PHP_SELF"] ??? ???? ??? ??????

    $ _SERVER ["PHP_SELF"]? htmlspecialchars() ??? ???? ?? ? ????.

    ? ??? ??? ????:

    <form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]) ;?>">

    htmlspecialchars() ?? ??? ?? ??? HTML ???? ?????. ?? ???? PHP_SELF ??? ????? ?? ??? ??? ?? ?????.

    <form method="post" action="test_form.php/"> <script> ??('???')</script>">

    ? ???? ???? ?????!


    PHP? ?? ?? ??? ??? ??

    ?? ?? ?? ? ?? PHP? htmlspecialchars() ??? ?? ?? ??? ???? ????.

    htmlspecialchars() ??? ??? ? ???? ??? ??? ??? ????? ??:

    <script>location.href('http :/ /www.hacked.com')</script>

    - ??? ??? ?? ????? ??? ????? ???? ????.

    <script>location.href('http://www.hacked.com')</script>

    ?? ? ??? ???? ???? ????? ???? ?????.

    ???? ??? ???? ?? ? ?? ??? ? ???? ???.

    1. (PHP Trim() ??? ??) ??? ?? ????? ???? ??(?? ??)? ?????. , ?, ? ??)

    2. (PHP ??????() ??? ??) ??? ?? ????? ???? ??()

    ???? ?? ??? ????(??? ???? ???? ?? ??). ?? ????? ????).

    ?? ??? test_input()?? ??????.

    ?? test_input() ??? ?? ? $_POST ??? ??? ? ????. ????? ??? ????.

    ?

    <!DOCTYPE HTML>
     <html>
     <head>
         <meta charset="utf-8">
         <title>PHP中文網(php.cn)</title>
     </head>
     <body>
     
     <?php
     // 定義變量并默認設置為空值
     $name = $email = $gender = $comment = $website = "";
     
     if ($_SERVER["REQUEST_METHOD"] == "POST")
     {
         $name = test_input($_POST["name"]);
         $email = test_input($_POST["email"]);
         $website = test_input($_POST["website"]);
         $comment = test_input($_POST["comment"]);
         $gender = test_input($_POST["gender"]);
     }
     
     function test_input($data)
     {
         $data = trim($data);
         $data = stripslashes($data);
         $data = htmlspecialchars($data);
         return $data;
     }
     ?>
     
     <h2>PHP 表單驗證實例</h2>
     <form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
         名字: <input type="text" name="name">
         <br><br>
         E-mail: <input type="text" name="email">
         <br><br>
         網址: <input type="text" name="website">
         <br><br>
         備注: <textarea name="comment" rows="5" cols="40"></textarea>
         <br><br>
         性別:
         <input type="radio" name="gender" value="female">女
         <input type="radio" name="gender" value="male">男
         <br><br>
         <input type="submit" name="submit" value="提交">
     </form>
     
     <?php
     echo "<h2>您輸入的內容是:</h2>";
     echo $name;
     echo "<br>";
     echo $email;
     echo "<br>";
     echo $website;
     echo "<br>";
     echo $comment;
     echo "<br>";
     echo $gender;
     ?>
     
     </body>

    ????? ???? ?????


    ??: ? ????? ??? ? $_SERVER["REQUEST_METHOD"]? ???? ??? ?????? ?????. REQUEST_METHOD? POST?? ??? ???? ???? ???? ?????. ??? ???? ??? ??? ??? ???? ???? ?????.

    ? ???? ????? ??? ??????, ???? ??? ???? ???? ??? ????? ??? ? ????.


    ?? ???? ???? ??? ???? ???? ???? ??? ?????.



    ???? ??
    ||
    <!DOCTYPE HTML> <html> <head> <meta charset="utf-8"> <title>PHP.cn</title> </head> <body> <h2>PHP 表單驗證實例</h2> <form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"> 名字: <input type="text" name="name" value=""> <br> E-mail: <input type="text" name="email" value=""> <br> 網址: <input type="text" name="website" value=""> <br> 備注: <textarea name="comment" rows="5" cols="40"></textarea> <br> 性別: <input type="radio" name="gender" value="female">女 <input type="radio" name="gender" value="male">男 <br> <input type="submit" name="submit" value="提交"> </form> </body> </html>

    • <code id="wnedn"></code>
      <thead id="wnedn"></thead>