Hi to the one who reads this, I am currently trying to make a website through PHP, its a game, or say an online Pokemon RPG. I have got many questions for it and I hope people can help me out. First of all the thing required is User Registration I tried my best to make some forms but sometimes I was unsuccessful or sometimes it worked but not efficiently or correctly. Plus the main thing I wanted was Image Verification and E-mail verification. Which I have doubts how to do. Next, I plan to make an Inbuilt Mail System and an Inbuilt Forums to discuss about games and other topics. I was successful, or say very much successful in this except a few things like: a)How to let people use BBcode and Smilies b)How to put a <br /> wherever use has press Enter. c)How to STOP user from using Some HTML codes, and refrain from using JS or PHP. I dont want to end up having a c99 in my website. Thats all for now, if anyone can help post here or drop me a PM.
b) http://www.php.net/manual/en/function.nl2br.php c) http://www.php.net/manual/en/function.strip-tags.php and http://www.php.net/manual/en/function.mysql-real-escape-string.php
BBCode and Smilies are more complex, and require you use to regular expressions, such as preg_replace . I'd lookup the source of phpBB for an example of how it's done. Jay
<?php function bbcode($text) { $pattern = array(); $replace = array(); $pattern[] = '/\[b\](.*?)\[\/b\]/i'; $replace[] = '<b>$1</b>'; $pattern[] = '/\[B\](.*?)\[\/B\]/i'; $replace[] = '<b>$1</b>'; $pattern[] = '/\[i\](.*?)\[\/i\]/i'; $replace[] = '<i>$1</i>'; $pattern[] = '/\[I\](.*?)\[\/I\]/i'; $replace[] = '<i>$1</i>'; $html = preg_replace($pattern, $replace, $text); return $html; } ?> PHP: This is more or less what I have been using.
I prefer htmlentities() over strip_tags() because it still displays the tags, just converts them to the proper entities .