

代码: (推荐学习:PHP视频教程)
<!DOCTYPE HTML> <html> <head> <meta charset="utf-8"/> <title>简单表单提交</title> </head> <body> <form action="welcome.php"> 姓名 <input type="text" name="name"/><br/><br/> 邮箱 <input type="text" name="email"/><br/><br/> <button type="submit" formmethod="GET">GET</button> <button type="submit" formmethod="POST">POST</button> </form> </body> </html>
<html>
<head>
<meta charset="utf-8"/>
<title>表单已提交</title>
</head>
<body>
<?php
$name = filter($_REQUEST['name']);
$email = filter($_REQUEST['email']);
function filter($data){
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data, ENT_QUOTES);
return $data;
}
?>
<p>你好,<?php echo $name; ?>!您的表单已提交成功!</p>
<p>更多信息会发送到您的邮箱:<?php echo $email; ?></p>
</body>
</html>