I Love PHPMaker

... because it gets even more powerful and flexible!!

  • About
  • Terms and Conditions
  • Membership Options
  • Sitemap
  • Downloads
    • PHPMaker Extensions Download
    • PHPMaker Projects Download
    • PHP Report Maker Extensions Download
I Love PHPMaker » Tips and Trick » How to Display a Welcome Message After Users Successfully Logged In to the Websites Generated with PHPMaker 8.0.3
How to Hide “Please Select” in the Select Option in Websites that Created with PHPMaker 8.0.3
How to Add Record Number Column on the Exported List Pages in Websites that Generated by PHPMaker 8.0.3

December 15, 2011

How to Display a Welcome Message After Users Successfully Logged In to the Websites Generated with PHPMaker 8.0.3

The following trick will show you how to display the welcome message to your users after they are successfully logged in to your web application that generated with PHPMaker 8.0.3. This message will be displayed on the first next page your users will see after they have successfully logged in to your site, no matter what page that they will see the first time after logged in.

The welcome message will include the complete name of your logged in user. For example, one of your users' username is: johndoe and the complete name of him is John Doe (first name is John, and the last name is Doe), so the welcome message that will be shown is: Welcome, John Doe!.

Please note that if you want to display the auto-hide message in three seconds, then please apply this customization.

All we have to do is customizing the PHPMaker template file and adding some code into the Server Events section of PHPMaker. In other words, we do not modify any generated script files.

Please click on the following image below to watch the demo:

Welcome Message After User Successfully Logged In
Welcome Message After User Successfully Logged In

[hidepost]

  1. Open your .pmp PHPMaker project file using your PHPMaker application, click on the Database icon on the toolbar, and then click on the Server Events/Clients Scripts tab, go to the Server Events -> Other -> Login Page -> User_LoggedIn, and then add the following code into that function:

        global $Security, $Language;
        $this->setSuccessMessage($Language->Phrase("Welcome").", ". $Security->CurrentCompleteName()."!"); 
    
  2. Make sure you have added the "Welcome" phrase into the C:\Program Files\PHPMaker 8\languages\english.xml file and also the other .xml language file (if any). To add a new phrase into the .xml language file, please read this article.
  3. Open your /Script/phpfn.php file, and find this code:

    	function setCurrentUserName($v) {
    		$_SESSION[EW_SESSION_USER_NAME] = $v;
    	}
    

    after the last line of that code, please insert this following code:

    	function CurrentCompleteName() {
    		global $conn;
    		$first_name = "nama_awal"; // <-- adjust it with your real first name field
    		$last_name = "nama_akhir"; // <-- adjust it with your real last name field
    		$currentUserName = $this->getCurrentUserName();
    		if (($rs = $conn->Execute("SELECT ".$first_name.", ".$last_name." FROM ".EW_USER_TABLE." WHERE ".EW_USER_ID_FIELD." = '".$currentUserName."'")) && !$rs->EOF) {
    			$completeUserName = $rs->fields($first_name) . " " . $rs->fields($last_name);
    			$rs->Close();	
    		}
    		return $completeUserName;
    	}
    

    Please do not forget to adjust the values of the $first_name and $last_name variables above.

  4. Open your /Script/ewcfg.php file, and find this code:

    define("EW_USER_NAME_FILTER", "<!--##=ew_Quote(sFilter)##-->",  TRUE);
    

    before the first line of that code, please insert the following code:

    <!--##
    	If PROJ.SecLoginIDFld <> "" Then
    		Set FIELD = SECTABLE.Fields(PROJ.SecLoginIDFld)
    		sFld = ew_FieldName
    	End If
    ##-->
    define("EW_USER_ID_FIELD", "<!--##=sFld##-->", TRUE);
    

[/hidepost]

Article by Masino Sinaga / Tips and Trick / login, message, PHPMaker 8.0.3, welcome 9 Comments

How to Hide “Please Select” in the Select Option in Websites that Created with PHPMaker 8.0.3
How to Add Record Number Column on the Exported List Pages in Websites that Generated by PHPMaker 8.0.3

Comments

  1. Salem says

    March 4, 2012 at 2:37 am

    “EW_USER_ID_FILTER” returns null !!! I hard coded it to get the function working.

    Log in to Reply
    • Masino Sinaga says

      March 4, 2012 at 6:59 am

      What do you mean “I hard coded it to get the function working”? I don’t think that “EW_USER_ID_FILTER” constant is used in this article.

      Log in to Reply
      • Salem says

        March 4, 2012 at 4:02 pm

        Sorry for the typo, I mean the constant “EW_USER_ID_FIELD” returns error (there is no such constant in php template, unless you’ve added it) , so I had to hardcode username field in the select statement.

        Log in to Reply
        • Masino Sinaga says

          March 4, 2012 at 5:07 pm

          Ah, I see. You are right. Apologize for the uncovenience, and thanks for bringing this issue up.

          Please follow the step number 4 in order to add the related constant into the configuration file.

          Log in to Reply
  2. Salem says

    March 5, 2012 at 11:19 pm

    It seems to me that you can accomplish the same using “server events – Global Code” without the need to edit the template … is there a reason behind it? .. maybe performance ?? Thanks.

    Log in to Reply
    • Masino Sinaga says

      March 6, 2012 at 8:46 am

      Well, the reason for this since I wanted to use the Security class that provided in the template file, so that I customized the class in the template file by adding the new function. In addition, this template can be re-used by another project without having to add the code from the Global Code section of PHPMaker application.

      Log in to Reply
      • Salem says

        March 7, 2012 at 4:01 pm

        Makes sense, Thanks 🙂

        Log in to Reply
  3. Adam Burgoyne says

    January 12, 2013 at 7:31 pm

    For 9.10, the following code:

        If PROJ.SecLoginIDFld  "" Then
            Set FIELD = SECTABLE.Fields(PROJ.SecLoginIDFld)
            sFld = ew_FieldName
        End If
    

    …needs to be changed to:

        if (ew_IsNotEmpty(PROJ.SecLoginIDFld)) {
            FIELD = SECTABLE.Fields(PROJ.SecLoginIDFld);
            sFld = ew_FieldSqlName(FIELD);
        }
    
    Log in to Reply
    • Masino Sinaga says

      January 12, 2013 at 9:04 pm

      Thanks for the feedback.

      Log in to Reply

Leave a Reply Cancel reply

You must be logged in to post a comment.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Recent Posts

  • A New PHPMaker 2020 Project File Is Released
  • PHPMaker 2020 Demo Project File Is Released
  • Masino Extensions for PHPMaker 2020 Is Released!
  • Inventory Stock Management Project, Why Should You Have It?
  • A New PHPMaker 2019 Project File Is Released!
  • PHPMaker 2019 Demo Project File Is Released!
  • Masino Extensions for PHPMaker 2019 Is Released!
  • A New PHPMaker 2018 Project File Is Released!
  • PHPMaker 2018 Demo Project File Is Released!
  • Masino Extensions for PHPMaker 2018 Is Released!

Search

Recent Comments

  • Masino Sinaga on Masino Extensions for PHPMaker 2019 Is Released!
  • Masino Sinaga on Masino Extensions for PHPMaker 2019 Is Released!
  • Brien Devine on Masino Extensions for PHPMaker 2019 Is Released!
  • Brien Devine on Masino Extensions for PHPMaker 2019 Is Released!
  • Masino Sinaga on Masino Extensions for PHPMaker 2019 Is Released!

Demo Website

  • Demo of I Love PHPMaker 2020 (MasinoExtensions).
  • Indonesia Post Offices.
  • Stock Inventory Management.
  • Demo of PHPMaker + PHP Report Maker

Another Demo

The following template are not available in this site (must be purchased separately)

  • PHPMaker v2018 Horizontal Vertical Template.
  • PHPMaker v2017 Horizontal Vertical Template.

Demo Explanation

Stock Inventory Management is the good project for your reference, since it uses the real example in the real world. Many useful features you can use from this project, such as how to add the Thousand and Decimal separator character, and also how to calculate multiple row in Grid-Add when End-Users are entering data into the Grid-Add mode.

Categories

  • Customize Template (103)
  • General (3)
  • PHP Report Maker (17)
  • PHP Report Maker Extensions (2)
  • PHPMaker Extensions (76)
  • Tips and Trick (72)

Articles based on version

  • PHPMaker 2020
  • PHPMaker 2019
  • PHPMaker 2018
  • PHPMaker 2017.0.7
  • PHPMaker 12.0.7
  • PHPMaker 11.0.6
  • PHPMaker 10.0.5
  • PHPMaker 9.2.0
  • PHPMaker 8.0.3
  • PHP Report Maker 12

(c) I Love PHPMaker 2010 - 2019 by Masino Sinaga | WordPress | Log in | Back to top