Re: ISSET() question
- From: mail.cedric.chevalier@xxxxxxxxx
- Date: Thu, 28 Feb 2008 04:54:05 -0800 (PST)
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
.
- References:
- ISSET() question
- From: major
- ISSET() question
- Prev by Date: Re: Soap server
- Next by Date: Re: page rendering stops after php error
- Previous by thread: Re: ISSET() question
- Next by thread: Re: ISSET() question
- Index(es):
Relevant Pages
|