PHP 表单验证
某厂面试归来,发现自己落伍了!>>> 1.通过PHP来验证表单数据 <!DOCTYPE HTML> <html> <head> </head> <body> <?php // define variables and set to empty values $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);//( PHP trim() 函数)去除用户输入数据中不必要的字符(多余的空格、制表符、换行) $data = stripslashes($data);//(PHP stripslashes() 函数)删除用户输入数据中的反斜杠(\) $data =