0
입력 한 금액이 greater than 100
이거나 error
인 경우 유효성을 검사해야하는 간단한 php
페이지를 만들었습니다. 내 함수는하지만 게시 할 때 호출하고 값이 100보다 작 으면 오류, 그리고 그것이 만약 <
를 사용해야합니다 당신에게 크거나 같은인지 기능을 실행하려는 때문에 양이 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>
누군가가 몇 가지 포인트를 원합니다. 이 익명의 사용자를 도울 때 부끄러워하고 다음 번에 문제가 해결 될 때까지 답변을 받고 나가서 다시는 볼 수 없게됩니다. –