Page 1 of 1

smiley and emocations help

Posted: Mon Jul 15, 2002 12:12 am
by harsha
how do i enable smileys and emocation in the guestbook
how should i do that should i use javascript or what :?::?::?:

Posted: Mon Jul 15, 2002 4:08 am
by ShrineMaster
If it's not a built in feature of the guest book script you will need to add it.

Usually you want to add the code for checking for smilies on the output side of the process so you don't add bloat to your database with IMG tags.

Code: Select all

$comments = str_replace ( "&#1111;:)]", "<IMG SRC="smile.gif">", $comments);
You can use that to create any variation of Emoticon you want.

Posted: Tue Jul 16, 2002 8:47 am
by bcp_2005
Here's what I' do:

(add this to the header part of your file)

<script>
function insertsmilie(kind) {
result = kind
document.form1.message.value = document.form1.message.value + result
document.form1.message.focus()

}
</script>

(add this to the body part of your file)

<HTML>
<HEAD>
<TITLE>Untitled Document</TITLE>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
</HEAD>

<BODY BGCOLOR="#FFFFFF">
<TABLE WIDTH="100%" BORDER="0">
<TR>
<TD COLSPAN="2" VALIGN="top">
<TABLE WIDTH="100%" BORDER="0" DWCOPYTYPE="CopyTableRow">
<TR>
<TD WIDTH="193" VALIGN="top">
<P>Insert Smilie:</P>
</TD>
<TD WIDTH="3%">
<DIV ALIGN="center" TABINDEX="102"><A HREF="#"><IMG SRC="assets/cool.gif" WIDTH="16" HEIGHT="16" onClick="insertsmilie('#cool')" BORDER="0" TABINDEX="102"></A>
</DIV>
</TD>
<TD WIDTH="3%">
<DIV ALIGN="center" TABINDEX="102"><A HREF="#"><IMG SRC="assets/dodgy.gif" WIDTH="16" HEIGHT="16" onClick="insertsmilie('#dodgy')" BORDER="0" TABINDEX="102"></A>
</DIV>
</TD>
<TD WIDTH="3%">
<DIV ALIGN="center" TABINDEX="102"><A HREF="#"><IMG SRC="assets/frown.gif" WIDTH="16" HEIGHT="16" onClick="insertsmilie('#frown')" BORDER="0" TABINDEX="102"></A>
</DIV>
</TD>
</TR>
</TABLE>
</TD>
</TR>
<TR>
<TD WIDTH="19%" VALIGN="top"> <SPAN CLASS="main">
<P>Message:</P>
</SPAN> </TD>
<TD WIDTH="81%">
<TEXTAREA NAME="message" COLS="50" ROWS="5" TABINDEX="2"></TEXTAREA>
</TD>
</TR>
</TABLE>
</BODY>
</HTML>

this is your form.

now, to process this add this to your file that process the post:

$message = ereg_replace("#cool","<img src=assets/cool.gif border=0>",$message);
$message = ereg_replace("#dodgy","<img src=assets/dodgy.gif border=0>",$message);
$message = ereg_replace("#frown","<img src=assets/frown.gif border=0>",$message);

ok, there's a few things you need to know: first if your form is not named 'form1' this will not work. to change this setting, find the code in the header portion of your webpage. change all the form1's to whatever you want. anyways if you have any questions just let me know!