Jump to content

Chat TextArea or what ?


Panjabel

Recommended Posts

To do that you need to find if they put a smiley in their text, then replace it with the image to the smiley.

 

So say everytime someone put this :)  You would want to replace it with a smiley.

 

<?php

$pattern = "";
$replacement = "<img src=\"path/smiley.jpg\">"; //This would be the path to the smiley pic
$string = "Hello "; //This would be whatever text you wanted to put a smiley in

echo preg_replace($pattern, $replacement, $string);

?>

Link to comment
Share on other sites

nope! still cant... textareas only show raw text... you cant put any images into a textbox... it'd just show the <img> now... with ie... the <div> can have a attrib of contenteditable... which would show images... but i dont think ff does support that...

Link to comment
Share on other sites

No! Of course images are not going to show up in the textarea. You take the raw text, insert it into the database, then perform the code I gave you above to display it to the screen.

 

I'm still confused on exactly what you are trying to do, so if you give me some more detail I can help you more.

 

If you don't want it in the textarea, why don't you just echo the text to the screen using echo or print?

Link to comment
Share on other sites

enter the text in a textbox, display the text in an iframe :P

They both look the same, at least with a little css...

or if you don't like iframes, then use a table cell, but iframe

will let you use scrollbars like the textbox will

Link to comment
Share on other sites

clicky clicky

 

http://dennisbillings.com/smiley.php

 

What you'll need to understand

 

http://weblogtoolscollection.com/regex/regex.php - regular expressions

 

http://w3schools.com/html/default.asp - HTML

 

http://php.net/ - PHP syntax and predefined functions

 

Patience....

 


<?php

IF(ISSET($_REQUEST['submit'])){

$string= $_REQUEST['text'];


$pattern = "/:\)/";
$replacement = "<img src=\"images/tongue.gif\">"; //This would be the path to the smiley pic

echo preg_replace($pattern, $replacement, $string);

}

?>

<form method="post" action="<?PHP $_SERVER['PHP_SELF']; ?>">
<textarea name="text"></textarea><br />
<input type="submit" name="submit" value="Submit">
</form>

 

Link to comment
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.