案例:PHP案例     状态:不可编辑再运行    进入横版
x
<form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"> 
 
1
2
<!DOCTYPE HTML> 
3
<html>
4
<head>
5
</head>
6
<body> 
7
8
<?php
9
// define variables and set to empty values
10
$name = $email = $gender = $comment = $website = "";
11
12
if ($_SERVER["REQUEST_METHOD"] == "POST") {
13
   $name = test_input($_POST["name"]);
14
   $email = test_input($_POST["email"]);
15
   $website = test_input($_POST["website"]);
16
   $comment = test_input($_POST["comment"]);
17
   $gender = test_input($_POST["gender"]);
18
}
19
20
function test_input($data) {
21
   $data = trim($data);
22
   $data = stripslashes($data);
23
   $data = htmlspecialchars($data);
24
   return $data;

 运行结果 
 北美留学生论坛