battleroyalex Posted April 5, 2006 Share Posted April 5, 2006 [code]How would I disable html and make tags like they have on the forums for my comment script?Like if i wanted <b> to be [bold] ect.[/code]Currently this is the code I need to implement this into: [code]<head> <title>Comment Page</title> </head> <body> <?php // comment.php include 'displaycomments.php'; //error handeling ini_set ('display_errors', 1); error_reporting (E_ALL & ~E_NOTICE); if (isset ($_POST['submit'])) {//handel the form. //connect and select db if ($dbc = @mysql_connect ('localhost', 'thegamegraal', '*******')) { if (!@mysql_select_db ('battleroyalex')) { die ('<p>Could not select the database because: <b>' . mysql_error() . '</b></p>'); } }else { die ('<p>Could not connect to mysql because: <b>' . mysql_error() . '<b></p>'); } // Define query $query = "INSERT INTO comment_entries (comment_id, name, comment, date_entered) VALUES (0, '{$_POST['name']}', '{$_POST['comment']}', NOW())"; //run query if (@mysql_query ($query)) { print '<meta http-equiv="refresh" content="0"><p>your comment has been added.</p>'; }else { print "<p>could not add comment because: <b>" . mysql_error() . "</b>. The query was $query.</p>"; } mysql_close(); } ?>[/code] Link to comment https://forums.phpfreaks.com/topic/6659-how-do-i-make-my-own-html-tags/ Share on other sites More sharing options...
ToonMariner Posted April 5, 2006 Share Posted April 5, 2006 google 'bbcode' - that should provide a tutorial somewhere.What you are actually doing is a series of string replacements when printing the string - so [b] becomes<b> etc. etc.I use regulat expressions to do this but they have taken me a couple fo days to learn to a level where I can use them to there full extent - to start with str_replace will do but you will find sometime down teh line that they are not pwoerful enough for what you want. Link to comment https://forums.phpfreaks.com/topic/6659-how-do-i-make-my-own-html-tags/#findComment-24199 Share on other sites More sharing options...
battleroyalex Posted April 5, 2006 Author Share Posted April 5, 2006 [!--quoteo(post=361958:date=Apr 5 2006, 11:10 AM:name=ToonMariner)--][div class=\'quotetop\']QUOTE(ToonMariner @ Apr 5 2006, 11:10 AM) [snapback]361958[/snapback][/div][div class=\'quotemain\'][!--quotec--]google 'bbcode' - that should provide a tutorial somewhere.What you are actually doing is a series of string replacements when printing the string - so [b] becomes<b> etc. etc.I use regulat expressions to do this but they have taken me a couple fo days to learn to a level where I can use them to there full extent - to start with str_replace will do but you will find sometime down teh line that they are not pwoerful enough for what you want.[/quote]I did google bbcode and all I get is how to edit forum bbcode and other useless stuff. I can't find anything on making your own. Link to comment https://forums.phpfreaks.com/topic/6659-how-do-i-make-my-own-html-tags/#findComment-24201 Share on other sites More sharing options...
trq Posted April 5, 2006 Share Posted April 5, 2006 [a href=\"http://www.phpclasses.org/browse/package/951.html\" target=\"_blank\"]A bbcode class[/a]. Link to comment https://forums.phpfreaks.com/topic/6659-how-do-i-make-my-own-html-tags/#findComment-24205 Share on other sites More sharing options...
wildteen88 Posted April 5, 2006 Share Posted April 5, 2006 Heres a tutorial [a href=\"http://www.phpit.net/article/create-bbcode-php/\" target=\"_blank\"]here[/a] for creating a BBCode function. Also when searching for BBCode tutorials make your search more specific such as: [a href=\"http://www.google.co.uk/search?num=100&hl=en&hs=Raq&safe=off&client=firefox-a&rls=org.mozilla:en-GB:official_s&q=PHP+BBcode+tutorial&spell=1\" target=\"_blank\"]PHP BBCode Tutorials[/a]. You'll get a much more better results rather than just searching for BBCode.If you want to learn how to create the buttons that insert the BBCode into a textarea then you might want to read [a href=\"http://www.thecodebehind.com/code/javascript/examples/javascript-textarea-buttons-bold-italic.aspx\" target=\"_blank\"]this[/a] tutorial. Link to comment https://forums.phpfreaks.com/topic/6659-how-do-i-make-my-own-html-tags/#findComment-24240 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.