Re: ISSET() question



On 28 fév, 08:51, major <extreme...@xxxxxxxxx> wrote:
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($_POST['varA'])||!isset($_POST['varB'])){
?>
<form action="isset.php" 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"><input 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";

}

?>

use empty() :

if ( ( isset($_POST['varA'] && !empty($_POST['varA']) ) || ...

ichevc
.



Relevant Pages

  • ISSET() question
    ... 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 ...
    (comp.lang.php)
  • Re: ISSET() question
    ... and proceeds as though it was set to some value. ... Apparently isset() is not working, because it thinks that a blank text ... It will also throw a warning. ... !empty() is exactly the same thing, but does not throw a warning. ...
    (comp.lang.php)