Jump to content

Value Check


mtgriffiths

Recommended Posts

Hey All,

 

Think this maybe easy but my head is gone and i cant think.

 

I am passing a value over from another page:

 

$Course = $_POST['Course'];

 

I want to check if this value is blank....if so display a message saying that it is blank and to try again.

If it is not blank then run the code below it.

 

Can anyone help?

 

Thanks in advance

 

Matthew

Link to comment
https://forums.phpfreaks.com/topic/97271-value-check/
Share on other sites

Matthew (great name by the way),

 

There is a great function called empty(), it returns FALSE if var  has a non-empty and non-zero value.

 

The following things are considered to be 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 just do a check like this:

 

if (!empty($Course)) {
   // other code here
} else {
   // try again code here
}

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/97271-value-check/#findComment-497742
Share on other sites

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.