PHP表單的驗證 來自w3c

2021-07-09 03:40:23 字數 1377 閱讀 8006

表單在傳遞過來時,進行如下檢測:

post型別

在傳遞成功後,進行如下操作:

1.去除字串兩邊的字元

2.將html標籤轉為實體

<?php

// 定義變數並設定為空值

$name = $email = $gender = $comment = $website = "";

//如果獲取到值為post型別

if ($_server["request_method"] == "post")

//test_input函式

function

test_input

($data)

?>

php - 驗證名字

以下**展示的簡單方法檢查 name 字段是否包含字母和空格。如果 name 字段無效,則儲存一條錯誤訊息:

$name = test_input($_post["name"]);

if (!preg_match("/^[a-za-z ]*$/",$name))

//preg_match() 函式檢索字串的模式,如果模式存在則返回 true,否則返回 false。

$email = test_input($_post["email"]);

// 定義變數並設定為空值

$nameerr = $emailerr = $gendererr = $websiteerr = "";

$name = $email = $gender = $comment = $website = "";

if ($_server["request_method"] == "post") else

} if (empty($_post["email"])) else

} if (empty($_post["website"])) else

} if (empty($_post["comment"])) else

if (empty($_post["gender"])) else

}?>

w3c統一驗證工具 W3C驗證程式更新

w3c統一驗證工具 w3c標記驗證器是用於檢查xhtml或html是否沒有錯誤的強大工具。不幸的是,它遭受著極其不友好的錯誤訊息的困擾,這會使新手很難驗證他們的標記問題。驗證器背後的團隊昨天發布了乙個全新版本,其中包含許多先前在beta版本中試用過的改進功能 此處為changelog 驗證器最有用的...

W3C是什麼意思 W3C標準簡介

什麼是w3c w3c是英文 world wide web consortium 的縮寫,中文意思是w3c理事會或全球資訊網聯盟。w3c組織是對網路標準制定的乙個非贏利組織,像html xhtml css xml的標準就是由w3c來定製。w3c的主要規範 到目前為止,w3c已開發了超過50個規範 草案...

PHP表單驗證 w3school PHP學習筆記

注意 在php處理表單時請注意資料的安全性head action test.php method post 姓名 type text name name 電郵 type text name email type text name website name comment rows 3 cols 2...