The following code processes a blank field as though it has some value
and proceeds as though it was set to some value.
Apparently isset() is not working, because it thinks that a blank text
field is set to something.
Please let me know how to use isset() correctly.
Thanks ahead.
<?php
if(!isset($_POS T['varA'])||!isset($_POS T['varB'])){
?>
<form action="isset.p hp" method="POST">
<table><tr>
<td>Value 1:</td><td><input type="text" name="varA" value=""></td></
tr>
<tr><td>Value 2:</td><td><input type="text" name="varB" value=""></
td></tr>
<tr><td colspan="2"><in put type="submit" value="submit"> </td></tr>
</table>
</form>
<?php
}
else {
$x=$_POST['varA'];
$y=$_POST['varB'];
if($x>$y){
echo "Value 1:".$x." is larger";
}else
echo "Value 2:".$y." is larger";
}
?>
and proceeds as though it was set to some value.
Apparently isset() is not working, because it thinks that a blank text
field is set to something.
Please let me know how to use isset() correctly.
Thanks ahead.
<?php
if(!isset($_POS T['varA'])||!isset($_POS T['varB'])){
?>
<form action="isset.p hp" method="POST">
<table><tr>
<td>Value 1:</td><td><input type="text" name="varA" value=""></td></
tr>
<tr><td>Value 2:</td><td><input type="text" name="varB" value=""></
td></tr>
<tr><td colspan="2"><in put type="submit" value="submit"> </td></tr>
</table>
</form>
<?php
}
else {
$x=$_POST['varA'];
$y=$_POST['varB'];
if($x>$y){
echo "Value 1:".$x." is larger";
}else
echo "Value 2:".$y." is larger";
}
?>
Comment