Jump to content

:: Form validation problems


anevins

Recommended Posts

This doesnt' work:

if (!empty($b_house) && !empty($b_postcode) && !empty($b_city) && !empty($b_country) && !empty($d_house) && !empty($d_postcode) && !empty($d_city) && !empty($d_country)){
...
}

 

replacing !empty with isset doesn't work either.

 

I just want to say if all of them are not empty, do the if statement.

 

Any solutions?

Link to comment
https://forums.phpfreaks.com/topic/232631-form-validation-problems/
Share on other sites

Perhaps one of them is actually empty hm? Check your inputs and outputs, see if they are what you expect. It's the first step of debugging.

 

Oh and just to be sure, empty deems the following to be classified as 'empty':

    "" (an empty string)

    0 (0 as an integer)

    "0" (0 as a string)

    NULL

    FALSE

    array() (an empty array)

    var $var; (a variable declared, but without a value in a class)

So they are all empty strings, yet you want to run the if statement if all of them are NOT EMPTY. Is that right?

 

From the code you've given, assuming all the variables mentioned are in fact not empty, the if statement should be triggered fine. However if one is empty then of course the statement will return false.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.