Forum Moderators: coopster
$purpose = $_POST['purpose'][
if ( $purpose == "hello" ) { echo "Hello!"; }
but when the site first loads, the page is loaded - without being accessed from any form. how do i tell it to do something if no form result exists? in other words, can i go...
if ( $puspose == nothing ) ...
of is there a better way?
any help appreciated
An often used approach is to test for the variable's existence and setting it to a default if it is not set.
$purpose = (isset($_POST['purpose'])) ? $_POST['purpose'] : '';See the Ternary Operator [php.net] for an explanantion of how this works.
So you can use either effectively with AFAIK no functional difference. Or am I missing something?