Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Enterprise
Expertise: Beginner
Oct 18, 1999

Display Greeting Message

Here is a simple way by which you can display a greeting message to a user at the time of login.There are certain scenarios where you can use this feature to provide a welcome message to the user, such as in case of a online book or music store.

In the following example function PrintGreetingMessage() takes in a user name and displays a message depending upon the time of the web server. The statement <%= PrintGreetingMessage("User Name") %> sends the return value of the function to the browser. Thus, a user viewing this page before 12:00 noon (in the Web server's time zone) would see following text:

 
Good Morning !!! "User Name"
And a user viewing the same page at or after 12:00 noon would see following text:
 
Hello !!! "User Name"
You can write some additional code to get the "User Name" using cookies, etc.
 
<%@ Language=VBScript %>
<HTML>
<HEAD><TITLE>Display Greeting Message</TITLE></HEAD>
<BODY>
<%
function PrintGreetingMessage(strUserName)
 dim strGreetingMessage

 ' Set a message depending upon the time
 if (Time >= #12:00:00 AM# and  Time < #12:00:00 PM#) then
  strGreetingMessage = "Good Morning !!! "
 else
  strGreetingMessage = "Hello !!! "
 end if
 ' return the message out to the HTML page
 PrintGreetingMessage = strGreetingMessage & strUserName
end function
%>

<%= PrintGreetingMessage("User Name") %>
</BODY>
</HTML>
Deepak Pant
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date