Jump to content

Recommended Posts

I am trying to get smleys to show up in my guestbook which is in flash. I use php to post name, email, comments, etc to the guestbook. right now I have it when I click on a smiley it puts for instance I have a smiley with thumbs up, when I click on it the word thumbsup is displayed in the comment box. Now when I hit submit I would like the smiley picture to show in guestbook instead of thumbsup. I am using a text file to store the info, which in turn is inputted into guestbook. Everything works great just havent figured out how to get picture to show up. If someone could help I would appreicate it very much so.

 

 

                                                                                      Kevin

Link to comment
https://forums.phpfreaks.com/topic/183259-show-smiley-in-gb/
Share on other sites

You could use str_replace

 

e.g.

 


$post = $_POST['message'];

$search  = array(
                  ':thumbsup:',
                  ':smileyTXT2:',
                  ':etc:'
                );
$replace = array(
                  '<img src="img/smile/thumbsUp.jpg" class="smiley" >',
                  '<img src="img/smile/smiley2.jpg" class="smiley" >',
                  '<img src="img/smile/etc.jpg" class="smiley" >' 
                );

$post = str_replace($search, $replace, $post);

 

See also str_ireplace which does the same thing but is not case sensitive.

 

Link to comment
https://forums.phpfreaks.com/topic/183259-show-smiley-in-gb/#findComment-967227
Share on other sites

Here is my php code I use for the Guestbook.

<?php

$Submit 	= $_POST["Submit"];
$Name 	        = $_POST["Name"];
$Email 	        = $_POST["Email"];
$Website 	= $_POST["Website"];
$Comments 	= $_POST["Comments"];
$State          = $_POST["State"];
$NumLow 	= $_REQUEST["NumLow"];
$NumHigh 	= $_REQUEST["NumHigh"];

$Name 	= ereg_replace("[^A-Za-z0-9 ]", "", $Name);
$Email 	= ereg_replace("[^A-Za-z0-9 \@\.\-\/\']", "", $Email);
$Website 	= eregi_replace("http://", "", $Website);
$Website 	= ereg_replace("[^A-Za-z0-9 \@\.\-\/\'\~\:]", "", $Website);
$State 	= ereg_replace("[^A-Za-z0-9 ]", "", $State);

$Comments = eregi_replace('&', ' and ',$Comments);
$Comments = eregi_replace('<', '*',$Comments);
$Comments = eregi_replace('>', '*',$Comments);
$Comments = eregi_replace('', '****',$Comments);
$Comments = eregi_replace('sh', '****',$Comments);
$Comments = eregi_replace('bi', '****',$Comments);
$Comments = eregi_replace('ba', '****',$Comments);
$Comments = eregi_replace('c', '****',$Comments);
$Comments = eregi_replace('s', '****',$Comments);
$Comments = eregi_replace('c', '****',$Comments);
$Comments = eregi_replace('w', '****',$Comments);
$Comments = eregi_replace('n', '****',$Comments);
$Comments = eregi_replace('g', '@#*!#%',$Comments);
$Comments = eregi_replace('s', '****',$Comments);
$Comments = eregi_replace('s', '$@*%!#',$Comments);
$Comments = eregi_replace('d', '****',$Comments);
$Comments = eregi_replace('p', '****',$Comments);
$Comments = eregi_replace('di', '$@*%!#',$Comments);
$Comments = eregi_replace('', '****',$Comments);
$Comments = eregi_replace('w', '****',$Comments);
$Comments = eregi_replace('', '#@%!$',$Comments);


$Name 	= stripslashes($Name);
$Email 	= stripslashes($Email);
$Website 	= stripslashes($Website);
$State 	= stripslashes($State);
$Comments 	= stripslashes($Comments);



if ($Submit == "Yes") {

$filename 	= "GuestBook.txt";

// Opens up the file declared above for reading 

$fp 		= fopen( $filename,"r"); 
$OldData 	= fread($fp, 80000); 
fclose( $fp ); 

// Gets the current Date of when the entry was submitted
$Today 		= (date ("l dS of F Y ( h:i:s A )",time()));

// Puts the recently added data into html format that can be read into the Flash Movie.
// You can change this up and add additional html formating to this area.  For a complete listing of all html tags
// you can use in flash - visit: http://www.macromedia.com/support/flash/ts/documents/htmltext.htm

$Input = "Name: <b>$Name</b>\nEmail: <b><u><a href=\"mailto:$Email\">$Email</a></u></b>\nWebsite: <b><u><a href=\"http://$Website\" target=\"_blank\">$Website</a></u></b>\nState: <b>$State</b>\nComments: <b>$Comments</b>\n <i><font size=\"-1\">\nDate: $Today</font>.:::.\n\n";

/* This Line adds the '&GuestBook=' part to the front of the data that is stored in the text file.  This is important because without this the Flash movie would not be able to assign the variable 'GuestBook' to the value that is located in this text file  */

$New = "$Input$OldData";

// Opens and writes the file.

$fp = fopen( $filename,"w"); 
if(!$fp) die("&GuestBook=cannot write $filename ......&");
fwrite($fp, $New, 800000); 
fclose( $fp ); 
}

// ###################################################################################
// ######### Formatting and Printing the Data from the Guestbook to the Flash Movie ##



// Next line tells the script which Text file to open.
$filename = "GuestBook.txt";

// Opens up the file declared above for reading 

$fp 	= fopen( $filename,"r"); 
$Data 	= fread($fp, 800000); 
fclose( $fp );

// Splits the Old data into an array anytime it finds the pattern .:::.
$DataArray = split (".:::.", $Data);

// Counts the Number of entries in the GuestBook
$NumEntries = count($DataArray) - 1;

print "&TotalEntries=$NumEntries&NumLow=$NumLow&NumHigh=$NumHigh&GuestBook=";
for ($n = $NumLow; $n < $NumHigh; $n++) {
print $DataArray[$n];
	if (!$DataArray[$n]) {
		Print "<br><br><b>No More entries</b>";
	exit;
	}
}
?>

 

Left bad words out no need to post them here ---lol. Now where would I put it in this code. This has missed with me for awhile now.

 

                                                              Thanks

Link to comment
https://forums.phpfreaks.com/topic/183259-show-smiley-in-gb/#findComment-967240
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.