Jump to content

$submit == true && -- losing my mind -- any ideas as a workaround?


programguru

Recommended Posts

if ($submit == 'true' && $name == '' || $email == '' || $msg == '') {
	$nomsgerr = "<span class=\"msg\">Please enter your information<br />in all fields marked with *.</span>";
}

 

The issue I am having is my Submit button seems to display my err message by default when my page loads. I figured

$submit == 'true' 

would create the err ONLY of the submit button was pressed, but it does not seem to be working!

 

All my other code (not posted) with submit is working fine, but I dont want

$nomsgerr 

to display if the submit button is not pressed.

 

Does anyone know a workaround?

Greaser,

 

Im not sure why, but I had to remove the

== 'true'
to make it work. Thanks for the tip its working now!

 

if ($submit && ($name == '' || $email == '' || $msg == '')) {
	$nomsgerr = "<span class=\"msg\">Please enter your information<br />in all fields marked with *.</span>";
}

in PHP everything that exists is "true" unless it is declared as "false" or "NULL"

 

so if

$submit="Hello"; //means $submit is not an empty string and exists in a true state
// so

if($submit) // evaluates to true because it exists and is not false or NULL

$submit = false; //means $submit exists in a false state
// so

if($submit) //evaluates to false

$submit = NULL; //means $submit doesnt exist
// so

if($submit) //evaluates to false

 

thats the way I look at it anyway

 

Paul,

 

Maybe I am just way too tired but you said:

 

in PHP everything that exists is "true" unless it is declared as "false" or "NULL"

 

Then

 

if($submit) //evaluates to false

 

It appears this would evaluate to true?

 

What you say? Am I in la la land?

because just above that line I had the line i changed thevalue of $submit

 

here is the same information but with the variable names changed as well to make it easier to read

 

$var1="Hello"; //means $var1 is not an empty string and exists in a true state
// so

if($var1) // evaluates to true because it exists and is not false or NULL

$var2 = false; //means $var2 exists in a false state
// so

if($var2) //evaluates to false

$var3 = NULL; //means $var3 doesnt exist
// so

if($var3) //evaluates to 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.