Page 1 of 1

Checking is field is empty

Posted: Wed Mar 30, 2011 1:07 pm
by mr.stana
HI,

im trying to check whether fields on my html page are empty. If they are i want a message to appear saying "youve not filled in all fields...etc." if they have filled it in then carry out the php. the code i have is:

Code: Select all

else if(is_null($firstname) || is_null($surname) || is_null($line1) || is_null($line2)|| is_null($country) || is_null($postcode) || is_null($telephonenumber) || is_null($cardhldname) || is_null($cardnumber) || is_null($country) || is_null($postcode) || is_null($telephonenumber) || is_null($cardhldname) || is_null($cardType) || is_null($securitynumber))
{
print ("Please make sure that all your fields have been filled in. Thank You.");
}

else{

do this code....

}
This code doesnt print the error if they leave the fields empty please advise!

Thanks,

Mike :) :banghead:

Re: Checking is field is empty

Posted: Wed Mar 30, 2011 2:08 pm
by AbraCadaver
Empty is not the same as null. Use:

Code: Select all

if(empty($firstname))

Re: Checking is field is empty

Posted: Thu Mar 31, 2011 8:41 am
by foxmahesh
use empty function instead of is_null