Redneckheaven Posted November 29, 2009 Share Posted November 29, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/183259-show-smiley-in-gb/ Share on other sites More sharing options...
Andy-H Posted November 29, 2009 Share Posted November 29, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/183259-show-smiley-in-gb/#findComment-967227 Share on other sites More sharing options...
Redneckheaven Posted November 29, 2009 Author Share Posted November 29, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/183259-show-smiley-in-gb/#findComment-967240 Share on other sites More sharing options...
Andy-H Posted November 29, 2009 Share Posted November 29, 2009 What is the variable that stores the string in which the values need to be replaced? Quote Link to comment https://forums.phpfreaks.com/topic/183259-show-smiley-in-gb/#findComment-967243 Share on other sites More sharing options...
Redneckheaven Posted November 29, 2009 Author Share Posted November 29, 2009 The Var is Comments for the comment_txt box where people type in their comments. Is that what your asking for? Now hte Var for the registery_txt box where the pictureis to show up in Guestbook is --GuestBook Quote Link to comment https://forums.phpfreaks.com/topic/183259-show-smiley-in-gb/#findComment-967245 Share on other sites More sharing options...
Redneckheaven Posted November 29, 2009 Author Share Posted November 29, 2009 What I have for each smiley is on(press) { Comments = Comments add "icon1"; } Quote Link to comment https://forums.phpfreaks.com/topic/183259-show-smiley-in-gb/#findComment-967268 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.