Jump to content

HTML doesn't process inside of text field


akumakeenta

Recommended Posts

I'm sure there have been those with this same problem.

 

I have a script that will not process HTML inside of a text box form.

 

I would like to type <b>bold</b> and that it come out bold instead of literally <b>bold</b>

 

What should I look for in the php script?

Is there something that they wrote in the php to strip the HTML code (make it literal code)?

or do I have to add php code to make it process the HTML?

 

Thanks for all your help in advance.

function bbcodes($message)
{
	$pattern[] = '#\[b\](.*?)\[/b\]#s';
	$pattern[] = '#\[i\](.*?)\[/i\]#s';
	$pattern[] = '#\[u\](.*?)\[/u\]#s';
	$pattern[] = '#\[quote](.*?)\[\/quote\]#is';
	$pattern[] = '#\[quote=(.*?)\](.*?)\[\/quote\]#is';
	$pattern[] = '#\[font=(.*?)\](.*?)\[/font\]#s';
	$pattern[] = '#\[size=(.*?)\](.*?)\[/size\]#s';
	$pattern[] = '#\[color=([a-zA-Z]*|\#?[0-9a-fA-F]{6})](.*?)\[/color\]#s';
	$pattern[] = '#\[left\](.*?)\[/left\]#s';
	$pattern[] = '#\[center\](.*?)\[/center\]#s';
	$pattern[] = '#\[right\](.*?)\[/right\]#s';
	$pattern[] = '/\[img\](.*?)\[\/img\]/is';

	$replace[] = '<strong>$1</strong>';
	$replace[] = '<em>$1</em>';
	$replace[] = '<u>$1</u>';
	$replace[] = '<div class="quote"><div class="quotetext">$1</div></div>';
	$replace[] = '<div class="quote"><div class="quotename">$1</div><div class="quotetext"><p>$2</p></div></div>';
	$replace[] = '<span style="font-family: $1;">$2</span>';
	$replace[] = '<span style="font-size: $1pt;">$2</span>';
	$replace[] = '<span style="color: $1">$2</span>';
	$replace[] = '<div style="text-align: left;">$1</div>';
	$replace[] = '<div style="text-align: center;">$1</div>';
	$replace[] = '<div style="text-align: right;">$1</div>';
	$replace[] = '<img src="$1" />';

	$message = preg_replace($pattern, $replace, $message);

return $message;
}

 

It will replace xxxxx => <b>xxxx</b>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.