you need to test for empty strings such as "" which variables have when you
submit an empty form ..

if(!empty(varname) && !empty(varname2) && !empty(varname 3)......){
//do whatever if they have something usefull in them
//this block of code will be ran if var_dumb() on all the
//vars tested is > than string(0)""
}else{
//do whatever if string()".." is anything else
}

----- Original Message -----
From: "Bryan Lipscy" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, February 06, 2003 12:20 AM
Subject: RE: [PHP] empty and isset


> Env:  Slackware 8.1, Apache 1.3.27, PHP 4.3.0
> Bugs: None found for these issues.
>
> I am running to this same problem.  The isset() function appears to have
> problems with the empty text value. The empty() function sees the value
> of $_POST['q1'] as expected.
>
> So why is both isset() and empty() returning true on q1?
>
> I included the is_null() to verify that the value is definitely not
> null.
>
> Submitting the empty form yields these results:
> Value of q1 ==
> Value of q1 is NOT NULL
> Q1 is empty
> q2 is empty
> q3 is empty
> q4 is empty
>
> Values for q2, q3, and q4 all return as expected.
>
>
> Source follows:
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
> <HTML>
> <HEAD>
> <TITLE> PHP Test </TITLE>
> <META NAME="Generator" CONTENT="EditPlus">
> <META NAME="Author" CONTENT="">
> <META NAME="Keywords" CONTENT="">
> <META NAME="Description" CONTENT="">
> </HEAD>
>
> <BODY>
> <FORM action="test.php" method="POST">
> <span id="q1">Text: <INPUT name="q1" type="text" maxlength="128"
> value=""></span><br>
> <span id="q2">Radio:
> <input name="qa2" type="radio" value="1">
> <input name="qa2" type="radio" value="2">
> <input name="qa2" type="radio" value="3">
> <input name="qa2" type="radio" value="4">
> </span><br>
> <span id="q3">Checkbox: <input type="checkbox" name="qa3"
> value="9"></span><br>
>
> <input type="submit" value="Submit"> <input type="Reset"
> name="Reset"><br>
>
> </FORM>
> </BODY>
> </HTML>
>
> PHP Source:
> <?
>
> if (isset($_POST['q1'])){
> print "Value of q1 == ".$_POST['q1']."<br>";
> }
>
> if (is_null($_POST['q1'])){
> print "Value of q1 is null<br>";
> } else {
> print "Value of q1 is NOT NULL<br>";
> }
>
> if (empty($_POST['q1'])){
> print "Q1 is empty<br>";
> }
>
> if (isset($_POST['q2'])){
> print "Value of q2 == ".$_POST['q2']."<br>";
> }
>
> if (empty($_POST['q2'])){
> print "q2 is empty<br>";
> }
>
> if (isset($_POST['q3'])){
> print "Value of q3 == ".$_POST['q3']."<br>";
> }
>
> if (empty($_POST['q3'])){
> print "q3 is empty<br>";
> }
>
> if (isset($_POST['q4'])){
> print "Value of q4 == ".$_POST['q4']."<br>";
> }
>
> if (empty($_POST['q4'])){
> print "q4 is empty<br>";
> }
>
> ?>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.443 / Virus Database: 248 - Release Date: 1/10/2003


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to