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

PHP ?? ??? ??


HTML ?? ??? ??

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

????? ? ??

????? ? ?? ??? ????? Javascript ???? ??? ?? ?????. ? ?? ??? ??? ??? ????? ??? ???? ??? ?? ??? ?? ????. ??.

??? ??

??? ?? ?????? ?? ??? ??? ??(?: ?????? ???)? ??? ? ????. ??, PHP ?????? ??? ??? ??? ???.

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

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

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

form1.jpg?? ?? ?

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

?? ? ? ? ? ? ? ? ? ? ??????????????????????????? ?????. +??? ??? ??? ? ????
???. + ??? ??? ???? ???('@' ? '.' ??)

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

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

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

??? ??

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

“??”: <input type="text" name="name">
">
?????????????? ????: <input type="text " name="website">
??????????????? ??: <textarea name="comment"rows="5" cols="40"< /textarea>
?????????????????????????????????????????~ >?? ??

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

????????????????????????????????????htmlspecialchars ($ _ Server ["pHP_Self"];? & gt; "& gt;

? ??? Method =" Post " ??? ???? ???? ?????.


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

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

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

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

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


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

&(????)? &"(????)? "

'(?????)? ???. ) be'

< (?? ??) ?<
> (?? ?) ?>

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

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

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

XSS? ??? ??? ???? ??? CSS(Cross-Site Script)??? ???. ???? ???? ???? ???? ??? ? ???? HTML ??? ???? ? ???? ??? HTML ??? ?????? ???? ???? ??? ??? ?????.

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

<?php echo $_SERVER["PHP_SELF "];?>">

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

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

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?? ? ? ?('???')%3C/script%3E ?????????????????????????????????????????????????????????????????????> ?? URL? ?? ??? ?? ???? ?????.

?????????????????????????????????????????????"test_form.php/"><script>alert('hacked')</script> ? ? ? ?>? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? "test_form.php/">< ;????>??('???') ? Javascript ??? ???? ??? ? ?????(????? ?? ??? ???). ?? ??? PHP_SELF ??? ??? ??? ? ??? ???? ??? ????.

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


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

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

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

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?>

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

& lt; ?? ?? = "???" ?? = "test_form.php/& quot; & lt; ???? & gt; ??('???') & lt;/script & gt;

<嘗> Try ???? ??????!

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

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

htmlspecialchars() ??? ??? ? ???? ?? ??? ??? ????? ???: ;/script> 'http://ipnx.cn')</script> ??>

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

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

PHP Trim() ??? ???? ????? ???? ??(?: ??, ?, ? ??)? ?????. ?? ???).

PHP ??????() ??? ???? ??? ?? ????? ????()? ?????


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

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

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

Instance

<?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;
}
?>

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

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

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

???? ??
||
<!DOCTYPE HTML> <html> <head> <meta charset="utf-8"> <title>PHP中文網(wǎng)</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> 網(wǎng)址: <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="Submit"> </form> <?php echo "<h2>您輸入的內(nèi)容是:</h2>"; echo $name; echo "<br>"; echo $email; echo "<br>"; echo $website; echo "<br>"; echo $comment; echo "<br>"; echo $gender; ?> </body>