Jump to content

Archived

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

legohead6

IF(variable = NULL)

Recommended Posts

it wont work...heres the code

[code]Code:

if($first = NULL
$last = NULL
$gun = NULL
$age = NULL
$saying = NULL
$email = NULL
$phone = NULL
$users = NULL
$passs = NULL){
......... [/code]


how do i make it work?

Share this post


Link to post
Share on other sites
Not sure what youre trying to do. Im assuming comare. so here it goes

if($first = NULL or
$last = NULL or
$gun = NULL or
$age = NULL or
$saying = NULL or
$email = NULL or
$phone = NULL or
$users = NULL or
$passs = NULL){

Share this post


Link to post
Share on other sites
im validating a form....i want it so if 1 or more of them is null then not to send the form....i have the rest of the code...just cant get that part

Share this post


Link to post
Share on other sites
Then that should work but its not a good method.

When the user presses submit, you should check like this.

if(empty($username)) {
echo "Must enter a username";
$username = false;
} else {
escape_data($username);
$username = TRUE;
}

Share this post


Link to post
Share on other sites
use the is_null() function

[code]if(is_null($var) || is_null($anotherVar))[/code]

Share this post


Link to post
Share on other sites
You'll want to code your if statement like so:
[code]if(is_null($first) || is_null($last) || is_null($gun) || is_null($age) || is_null($saying) || is_null($email) || is_null($phone) || is_null($users) || is_null($pass))
{
    echo "Please fill in all fields!";
}
else
{
    //process form data
}[/code]

Share this post


Link to post
Share on other sites

×

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.