smiley and emocations help

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
harsha
Forum Contributor
Posts: 103
Joined: Thu Jul 11, 2002 1:35 am
Location: Bengaluru (Bangalore) > Karnataka > India

smiley and emocations help

Post by harsha »

how do i enable smileys and emocation in the guestbook
how should i do that should i use javascript or what :?::?::?:
ShrineMaster
Forum Newbie
Posts: 7
Joined: Mon May 20, 2002 5:33 am

Post 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.
bcp_2005
Forum Newbie
Posts: 1
Joined: Tue Jul 16, 2002 8:47 am

Post 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!
Post Reply