PHP验证来检查文本字段不起作用

时间:2018-10-26 17:57:12

标签: php validation isset

我正在尝试创建一个简单的税务计算器,并且需要验证两个文本字段,以便它们不为空并且似乎没有任何提示?

if(isset($_GET['taxSubmit'])) {
    $afterPrice = $_GET['taxPrice'];
    $taxRate = $_GET['taxRate'];

    $beforeTax = ($afterPrice * 100) / ($taxRate + 100);
if(!empty($_GET['taxPrice'.'taxRate'])){
    echo "<h1>Price before tax = &pound;".$beforeTax."<h1>";
} else {
    echo 'All Fields Required';
}
}

有人要求标记,所以在这里:

<form method="get" action="watWk5.php"> 
<fieldset>
    <legend>Without tax calculator</legend>
    <label for="">After Tax Price</label>
    <input type="text" name="taxPrice"/ value=<?php
        if(isset($_GET['taxPrice'])){
            echo $_GET['taxPrice']; 
        }
        ?>>
    <label for="">Tax Rate</label>
    <input type="text" name="taxRate"/ value=<?php
        if(isset($_GET['taxRate'])){
            echo $_GET['taxRate']; 
        }
        ?>>
    <input type="submit" value="Submit" name="taxSubmit"/>
    <button type="reset" value="Reset" name="clrButton">Clear</button>
</fieldset>    

1 个答案:

答案 0 :(得分:1)

每个变量应有自己的public async Task<bool> DoesSecretExist(string accessToken, string keyVaultBaseUrl, string secretName) { var kvClient = new KeyVaultClient(accessToken); try { IPage<SecretItem> secretVersions = await kvClient.GetSecretVersionsAsync(keyVaultBaseUrl, secretName) .ConfigureAwait(false); if (!secretVersions.Any()) return false; return true; } catch (Exception ) { throw; } } 检查

!empty()