mtgriffiths Posted March 21, 2008 Share Posted March 21, 2008 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 More sharing options...
Orio Posted March 21, 2008 Share Posted March 21, 2008 [code<?php if(empty($Course)) //or $Course == "" //$Course is "" ?> Orio. Link to comment https://forums.phpfreaks.com/topic/97271-value-check/#findComment-497739 Share on other sites More sharing options...
cooldude832 Posted March 21, 2008 Share Posted March 21, 2008 <?php if(empty($var)){ #its not set or empty } ?> Link to comment https://forums.phpfreaks.com/topic/97271-value-check/#findComment-497740 Share on other sites More sharing options...
mb81 Posted March 21, 2008 Share Posted March 21, 2008 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 More sharing options...
mtgriffiths Posted March 21, 2008 Author Share Posted March 21, 2008 Thanks guys Worked great! Matthew Link to comment https://forums.phpfreaks.com/topic/97271-value-check/#findComment-497764 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.