Jump to content

Archived

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

battleroyalex

How Do I make My Own HTML tags?

Recommended Posts

[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]

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
[!--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.

Share this post


Link to post
Share on other sites
[a href=\"http://www.phpclasses.org/browse/package/951.html\" target=\"_blank\"]A bbcode class[/a].

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

×

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.