0
我创建了一个简单的php
页面,需要验证输入的金额是greater than 100
还是必须返回error
。我的功能虽然发布时不会被调用且金额less than 100
函数未验证
<html>
<head></head>
<title></title>
<style>
.error {color: #FF0000;}
</style>
<body>
<?php
function test_input($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
$amountErr = "";
$amount = "";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if (($_POST["amount"]) > 100) {
$amountErr = "Value must be equal or greater than 100";
} else {
$amount = test_input($_POST["amount"]);
}
}
?>
<form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>">
<p><span class="error">*required field.</span></p>
Amount:<input type="text" name="amount"/>
<span class="error">*<?php echo $amountErr; ?></span>
<input type="submit" value="Pay"/>
</form>
</body>
</html>
@Karl有人想要点。当你帮助这些匿名用户时感到羞愧,他们只是回答并离开,永远不会再被看到,直到他们的下一期。 –