Jump to content

[SOLVED] if this AND this AND this AND this...


RyanSF07

Recommended Posts

Hi All,

 

How can I confirm multiple variables are true, as in:

 

If AND ONLY IF 1, 2, 3, and 4 are true -- do this ___.

Otherwise, do this ___.

 

If I only confirm $a and $b (see below), this works. As soon as I throw in a couple more variables, though, it doesn't.

 

Thanks for your help!

Ryan

 

if ($_POST[submit]) {

// php validation 
if ($_POST[first_name] <> "") {
	$a = TRUE;
} else {
	$a = FALSE;
	$content .= "<p>Please click your browser's BACK button and enter your first name.</p>\n";
}
if ($_POST[last_name] <> "") {
	$b = TRUE;
} else {
	$b = FALSE;
	$content .= "<p>Please click your browser's BACK button and enter your last name.</p>\n";
}

if ($_POST[email] <> "") {
	$c = TRUE;
} else {
	$c = FALSE;
	$content .= "<p>Please click your browser's BACK button and enter your email.</p>\n";
}
if ($_POST[password] <> "") {
	$d = TRUE;
} else {
	$d = FALSE;
	$content .= "<p>Please click your browser's BACK button and choose a password.</p>\n";
}


if ($a.$b.$c AND $d) {............

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.