[英]How do I let php know that I made changes In input?
好吧,我有這個 html:
<?php if(isset($_POST['do_change'])) { // that is the place where i need to place if(changes have been made in input) echo "yeey y made changes"; }?>
<form action="changes.php" method="POST"> <input type="text" name="goose"> <input type="text" name="cat"> <input type="submit" name="do_change"> </form>
我需要<input name="goose" value="hey">
和<input name="cat" value="">
顯示文本:“你在輸入中寫了一些名字為 goose 而沒有名字為 cat 的東西”
要檢查用戶是否填寫了多個文本輸入字段,例如,您可以執行以下操作:
// array with names of the fields you want to check
$fieldnames = ['goose', 'cat', 'kangaroo'];
// initialize counter of filled fields with 0
$filled = 0;
// loop over the field names
foreach($fieldnames as $fieldname) {
// check if a value under that name exists in the $_POST array,
// and if so, that its value is not the empty string
if(isset($_POST[$fieldname]) && $_POST[$fieldname] !== '') {
$filled++;
}
}
if($filled > 1) {
echo 'You filled more than one field.';
}
你忘了{}
第一頁:
<form action="changes.php" method="POST">
<input type="text" name="goose">
<input type="submit" name="do_change">
</form>
更改。php:
if(isset($_POST['do_change'])){
// that is the place where i need to place if(changes have been made in input)
echo "yeey y made changes";
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.