Birthday Greetings On Log-in - Postet den (2061 Views)
Average Member
richfed
Innlegg: 999
999
A while back, I noticed that on my birthday, when I visited this site, there was a "Happy Birthday" message to me up by the log-in area of the forum header.
Does anyone have the code to add this to my forum? It was pretty neat!<
   
 Sidestørrelse 
Postet den
Advanced Member
Carefree
Innlegg: 4224
4224
You could embed this routine wherever you want the HB to show:

Code:

	if strAgeDOB > "" then
strSql="SELECT M_DOB FROM " & strMemberTablePrefix & "MEMBERS WHERE M_NAME='" & strDBNTUserName & "'"
set rsHB=my_Conn.Execute(strSql)
Member_DOB=rsHB("M_DOB")
rsHB.Close
set rsHB=Nothing
TDay=DoubleNum(Month(Date())) & DoubleNum(Day(Date()))
if mid(Member_DOB, 5, 4) = TDay then
Response.Write " <tr>" & vbNewLine & _
" <td align=""right"">Happy Birthday!</td>" & vbNewLine & _
" </tr>" & vbNewLine
end if
end if
<
Postet den
Snitz Forums Admin
RichardKinser
Innlegg: 16655
16655
This is how it's implemented here:

First add the following to inc_func_common.asp:

Code:
function isbday
if strAgeDOB = "1" and MemberID > 0 then
set rsbday = my_Conn.Execute ("SELECT M_DOB FROM " & strMemberTablePrefix & "MEMBERS WHERE MEMBER_ID = " & MemberID & " AND M_DOB <> ''")

if rsbday.EOF then
isbday = "no"
else
if day(StrToDate(rsbday("M_DOB") & "000000")) = day(strForumTimeAdjust) and month(StrToDate(rsbday("M_DOB") & "000000")) = month(strForumTimeAdjust) then
isbday = "yes"
else
isbday = "no"
end if
end if
set rsbday = nothing
else
isbday = "no"
end if
end function


function getGreeting()
if isbday = "yes" then
Response.Write "Happy Birthday!"
else
Response.Write "You are logged on as"
end if
end function

Then in inc_header.asp around line #392 find:

Code:
"                <td align=""center""><font face=""" & strDefaultFontFace & """ size=""" & strFooterFontSize & """>You are logged on as<br />"
and replace with:
Code:
"                <td align=""center""><font face=""" & strDefaultFontFace & """ size=""" & strFooterFontSize & """>"
call getGreeting()
Response.Write "<br />" & vbNewLine
<
Postet den
Senior Member
leatherlips
Innlegg: 1838
1838
That's nice! I didn't know it did that. I've never input my birthday before. I just added it to my site. smile<
Postet den
Senior Member
leatherlips
Innlegg: 1838
1838
You can also add a little graphic before the birthday such as a birthday cake. I have the events calendar mod installed so I just used it.
I changed this line:
Code:
Response.Write "Happy Birthday!"
To this:
Code:
Response.Write "" & getCurrentIcon(strCalIconBDay,"Happy Birthday!","vAlign=""middle""") & " <b>Happy Birthday!</b>"
<
Postet den
Advanced Member
Carefree
Innlegg: 4224
4224
Originally posted by RichardKinser
This is how it's implemented here ....

Richard, there's no call to "isbday" function that way. Since nothing else uses the functions, couldn't you combine them (as below) & call isbday instead?
Code:

function isbday
if strAgeDOB = "1" and MemberID > 0 then
set rsbday = my_Conn.Execute ("SELECT M_DOB FROM " & strMemberTablePrefix & "MEMBERS WHERE MEMBER_ID = " & MemberID & " AND M_DOB <> ''")
if rsbday.EOF then
isbday = "no"
else
if day(StrToDate(rsbday("M_DOB") & "000000")) = day(strForumTimeAdjust) and month(StrToDate(rsbday("M_DOB") & "000000")) = month(strForumTimeAdjust) then
isbday = "yes"
else
isbday = "no"
end if
end if
set rsbday = nothing
else
isbday = "no"
end if
if isbday = "yes" then
Response.Write "Happy Birthday!"
else
Response.Write "You are logged on as"
end if
end function
<
Postet den
Forum Admin
HuwR
Innlegg: 20611
20611
yes you could, but if you wanted to use it in the future you would then have to re-extract the isbdy function, so I owuld leave it as 2 functions, makes no difference in terms of execution and makes it more flexible.<
Postet den
Advanced Member
Carefree
Innlegg: 4224
4224
OK - then in our "inc_header.asp", we'd have to call isbday just before calling getGreeting().<
Postet den
Forum Admin
HuwR
Innlegg: 20611
20611
no, but you need to change this line in callgreeting
if isbday = "yes" then

to be
if isbday() = "yes" then<
Postet den
Advanced Member
Carefree
Innlegg: 4224
4224
I knew something didn't look right about that function, mind playing tricks on me again.
Tx HuwR<
Postet den
Average Member
richfed
Innlegg: 999
999
Thank you, Lads!<
Du må legge inn en melding