我有一个包含少量输入字段和更新选项的表单,假设我有10个字段并且我只更新前两个字段而不是其他可以显示消息的消息,只有第一个字段A和B更新使用PHP和Mysqli
在屏幕截图中,如果我更新了账单ID和来源的值,我应该在其他一些页面中显示消息,说明账单ID和来源已经用" xyz"值
答案 0 :(得分:0)
一种方法是获取具有真实和旧名称的字段,即
Select name,name as old_name from table
在html中
<input type="text" name="name" value="name from db">
<input type="hidden" name="old_name" value="old_name from db">
提交表格后,您可以查看。
在发布后检查。
If(post['name']==post['old_name'])
像这样。
另一种方法是通过检查onchange事件来自js
答案 1 :(得分:-1)
HTML:
<html>
<body>
//action is defining the php file's name which the form will be sent to ;
//method is defining the method which the form will be sent with
<form action="updateCheck.php" method="post">
<input type="text" name="input-filed-1"/>
<input type="text" name="input-filed-2"/>
<input type="text" name="input-filed-3"/>
<input type="text" name="input-filed-4"/>
<input type"text" name="input-filed-5"/>
<input type="submit" value="submit/>
</form>
</body>
</html>
在同一目录中创建名为updateCheck.php的文件,然后输入以下代码
<?php $updateMessage = "you have updated the following fields";
for($x = 0 ; $x<=5 ; $x++)
{
// trim for erasing the whitespaces
// that if clause checks if there was data entered in the update input fields
if(isset($_POST["input-field-".$x]) && trim($_POST["input-field-".$x]))
{
$updateMessage.= "input-field-".$x ;
}
}
echo "<script type='text/javascript'>alert('".$updateMessage."')</script>"
?>
我还没有对代码进行测试..但仔细研究它,你会看到它是如何完成的