Not displaying the error message in tree login page
<p>I have a tree login page as my first page in a survey. The issue is that , if the user does not select any node and clicks on the next button he is redirected to the same page . The problem is that he does not get any error message . </p>

<p>I want the user to get an error message 'Please select a group' 
Please look into the below code which does this action </p>

<p>(P.S check the Display() function ) </p>

<p>Correct me where I am going wrong </p>

<pre><code>&lt;?php
/**
 *  File:  TreeLoginWidget.php
 *
 *
 *  Purpose: display tree page.
 *
 *  Dependents:   none
 *
 *  Dependencies: SurveyItem
 *
 *  Classes:
 *    1. PinWidget
 *
 *  Interface/public functions:
 *
 *  Notes: ???
 *
 * Todo: none
 *
**/

class DisplayTreeLoginWidget extends DisplayItem
{

    function DisplayTreeLoginWidget(&amp; $sourceObj)
    {
        // debug
        if( $pDebugTraceFlag == _ID_FLAG_ON ) GDebugTraceFunc( __CLASS__." :: ".__FUNCTION__ );
        $this-&gt;node = 0;
        $surveywidget = getDataFromSession("surveywidget");
        DisplayItem::DisplayItem();
        $_SESSION["profile"]["rootNode"]=0;
        if($_GET["nodeId"]) {
            setDataToSession("postVar","");
        }
        $this-&gt;sourceObj =&amp; $sourceObj;
    }

    /**
     * Purpose: display pin page label text
     *
     * Input Params:   none
     *
     * Output Params:  none
     *
     * Return Value:   none
     *
     * Notes:
    */

    function display()
    {
        global $skin_path,$skin,$path;
        setDataToSession("skipPage", 0);
        setDataToSession('HideSave&amp;Resume',0);
        $currentPageNumber = currentPageNumber();
        if($currentPageNumber!=1) {
            setDataToSession('HideSave&amp;Resume',1);
        }

        echo "&lt;script type=\"text/javascript\" src=\"".$path."../lib/java/commonFuncs.js\"&gt;&lt;/script&gt;";

        // include the header
        include_once ("../lib/include/path.inc.php");
        include_once ("../lib/include/jshelper.php");
        include_once("display/tree.inc.php");
        include_once("display/commonTreeLayout.php");
        include_once ("../lib/include/commonTreeCode.php");

        setUpTreeAppProperty();
        $postVar = getDataFromSession("postVar");

        if(is_array($postVar)) {
            $_POST = $postVar;
        }

        if($this-&gt;sourceObj-&gt;displayType == "expanded") {
            $postVar["Expand_All"] = "Expand All";
            $this-&gt;sourceObj-&gt;displayType = "";
        }
        if($this-&gt;sourceObj-&gt;levelShowing != "") {
            setDataToSession("levelShowing",$this-&gt;sourceObj-&gt;levelShowing);
        }

        setUpElist($postVar, $_GET);
        $verifiedStartingNode = getTreeStartingNode();

        /** $matchedIdArr contains matched nodeIds or empty if no matches found/no search performed */
        $matchedIdArr = doSearch($verifiedStartingNode, $postVar);
        $eList = getEList();

        $Tree = new TreeWithRadioButton($this-&gt;sourceObj);

        $Tree-&gt;reSetupElist();

        $startingNode = &amp;$Tree-&gt;nodesArr[$verifiedStartingNode];
        echo "&lt;div class=\"body2 IE6trans\"&gt;";

        displaySearchTable();

        if(!$postVar["searchSubmit"]) {
            $matchedIdArr = array(getDataFromSession("data,node_id"));
        }

        displayTree('Search Organization Structure', '', '', $startingNode, $eList, $matchedIdArr, $maxDepth, get_path_prefix(),$this-&gt;sourceObj-&gt;_errorMsg,$this-&gt;sourceObj-&gt;_prompt);

        echo "&lt;script type=\"text/javascript\"&gt;";
        echo "$(document).ready(function () { $('input[name=\"wildText\"]').keyup(function(event){  if(event.keyCode == 13){ $('input[name=\"searchSubmit\"]').click(); } }); });";
        echo "&lt;/script&gt;";

        echo "&lt;/div&gt;";
    }

    /**
     * Purpose:  storing error message to _errorMsg
     *
     * Input Params:   none
     *
     * Output Params:  none
     *
     * Return Value:   Boolean - true or false
     *
     * Notes:
    */

    function validate()
    {
        // debug
        if( $pDebugTraceFlag == _ID_FLAG_ON ) GDebugTraceFunc( __CLASS__." :: ".__FUNCTION__ );     
        $surveywidget = getDataFromSession('surveywidget');
        $this-&gt;getPostData();
        $this-&gt;sourceObj-&gt;_errorMsg = "";
        $lastVisitedWidgetOid_Tree = getDataFromSession("lastVisitedWidgetOid_Tree");       
        setDataToSession("lastVisitedWidgetOid" , $lastVisitedWidgetOid_Tree);

        setLoginUserLanguage($this-&gt;node);

      $operations = ((strcmp($this-&gt;operation,getText2($surveywidget-&gt;saveResumeButtonText)) == 0)||
                                    (strcmp($this-&gt;operation,getText2($surveywidget-&gt;backButtonText)) == 0)||
                                    (strcmp($this-&gt;operation,getText2($surveywidget-&gt;nextButtonText)) == 0));

        if(($operations) &amp;&amp; ($this-&gt;node != ""))    {
            setDataToSession("data,node_id",$this-&gt;node);

            // used to track the node id assigned to this pin when more than one login is used
            setDataToSession("tree_login,node_id",$this-&gt;node);
            setDataToSession("tree_login_before_saveresume,node_id",$this-&gt;node);


            //Custom - 
            $oids = getListOfOidAndNodes(Array($this-&gt;node));
            $_SESSION["conditionNodeList"] = $oids;
            //End Custom

            if(!getDataFromSession('multiLoginIndex')) {
                $multiLoginIndex = 1;
            } else {
                $multiLoginIndex = getDataFromSession('multiLoginIndex');
            }
            $multiLoginIndex++;
            setDataToSession("multiLoginIndex",$multiLoginIndex);

            $this-&gt;sourceObj-&gt;_errorMsg = "";
        } else if(($operations) &amp;&amp; ($this-&gt;node == "")){
            $this-&gt;sourceObj-&gt;_errorMsg = "Please select a group";
            return false;
        } else {
            return false;
        }

        if($this-&gt;node == "") {
            $this-&gt;node = 0;
        }
        // user click save&amp;resume before visiting login page, we are redirecting to login page, That time user enter invalid node_id we are mainting save&amp;resume flag to 1 for displaying submitbutton(it act like as save&amp;resume)
        if(getDataFromSession('save&amp;resumeflag') == 1) {
            setDataToSession('save&amp;resumeloginpage',1);
        }

        return true;
    }

    /**
     * Purpose: get post data
     *
     * Input Params:   none
     *
     * Output Params:  none
     *
     * Return Value:   none
     *
     * Notes:
    */

    function getPostData()
    {
        // debug
        if( $pDebugTraceFlag == _ID_FLAG_ON ) GDebugTraceFunc( __CLASS__." :: ".__FUNCTION__ );
        $postVar["exactText"] =    (empty($_REQUEST["exactText"])==1)    ?""      :stripslashes($_REQUEST["exactText"]);
        $postVar["wildText"] =     (empty($_REQUEST["wildText"])==1)     ?""      :stripslashes($_REQUEST["wildText"]);
        $postVar["searchSubmit"] = (empty($_REQUEST["searchSubmit"])==1) ?""        :$_REQUEST["searchSubmit"];
        $postVar["Collapse_All"] = (empty($_REQUEST["Collapse_All"])==1) ?""        :$_REQUEST["Collapse_All"];
        $postVar["idText"] =       (empty($_REQUEST["idText"])==1)       ?""      :$_REQUEST["idText"];
        $postVar["node"] =         (empty($_REQUEST["node"])==1)         ?""      :$_REQUEST["node"];
        $this-&gt;node =              ($_REQUEST["node"] == "")             ?""      :$_REQUEST["node"];
        $this-&gt;operation =         (empty($_REQUEST["Operation"])==1)    ?""      :$_REQUEST["Operation"];

        if($postVar["Collapse_All"]) {
            $postVar["wildText"] = "";
        }

        setDataToSession('postVar',$postVar);
        setDataToSession('Operation',$this-&gt;operation);
        setDataToSession('node',$this-&gt;node);
    }

}
?&gt;
</code></pre>
