检查文本字段的php验证无效
我正在尝试创建一个简单的税务计算器,需要验证这两个文本字段,以便它们不为空,并且看起来不起任何作用检查文本字段的php验证无效,php,validation,isset,Php,Validation,Isset,我正在尝试创建一个简单的税务计算器,需要验证这两个文本字段,以便它们不为空,并且看起来不起任何作用 if(isset($_GET['taxSubmit'])) { $afterPrice = $_GET['taxPrice']; $taxRate = $_GET['taxRate']; $beforeTax = ($afterPrice * 100) / ($taxRate + 100); if(!empty($_GET['taxPrice'.'taxRate'])){
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 = £".$beforeTax."<h1>";
} else {
echo 'All Fields Required';
}
}
if(isset($\u GET['taxSubmit'])){
$afterPrice=$_GET['taxPrice'];
$taxRate=$_GET['taxRate'];
税前美元=($afterPrice*100)/($taxRate+100);
如果(!empty($_GET['taxPrice.'taxRate'])){
echo“税前价格=£;”,税前美元;
}否则{
回显“所有必填字段”;
}
}
有人要了标记,所以这里是:
<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>
不含税计算器
税后价格
>
清楚的
每个变量都应该有自己的
!空()
检查
if(!empty($_GET['taxPrice']) && !empty($_GET['taxRate'])) {
//proceed
} else {
//throw error
}
你说的“似乎不起作用”是什么意思?也向我们显示您的表单标记。此
如果(!empty($\u GET['taxPrice.'taxRate']){
看起来有误。它们应该是分开的!empty()
检查不串联只需一秒钟我会更新代码是的,谢谢这是工作,我可以随时将其标记为正确。;)