rickyj Posted April 4, 2007 Share Posted April 4, 2007 Hi, I'm running into something that seems quite trivial. I'm primarily a java programmer, but am creating a web site that has a bit of php code. The problem is, I have created a search page in php that querries a db, and returns to self with the results. One of the problems im having is that if a user goes directly to search php, then there is an error thrown because there is no variable sent to this page. I need a way of "catching" this error without having to define. I have tried something like: php: if( $_POST['myVar'] == NULL ){ $variableDefinedfromMyVar = "no search submited"; } // problem is "$_POST['myVar']" thows an error since myVar is undefined I also need to catch other nonsubmitted variables but cant see how ???? any suggestions Link to comment https://forums.phpfreaks.com/topic/45602-php-how-to-catch-if-a-variable-is-never-sent-post-or-get/ Share on other sites More sharing options...
hitman6003 Posted April 4, 2007 Share Posted April 4, 2007 Try the isset, empty, and is_null functions... http://www.php.net/isset http://www.php.net/empty http://www.php.net/is_null Link to comment https://forums.phpfreaks.com/topic/45602-php-how-to-catch-if-a-variable-is-never-sent-post-or-get/#findComment-221429 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.