Jump to content


Photo

How Do I make My Own HTML tags?


  • Please log in to reply
4 replies to this topic

#1 battleroyalex

battleroyalex
  • Members
  • Pip
  • Newbie
  • 6 posts

Posted 05 April 2006 - 03:00 PM

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.

Currently this is the code I need to implement this into:

<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();

       }
       ?>


#2 ToonMariner

ToonMariner
  • Members
  • PipPipPip
  • Advanced Member
  • 3,342 posts
  • LocationNewcastle upon Tyne, UK

Posted 05 April 2006 - 03:10 PM

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.
follow me on twitter @PHPsycho

#3 battleroyalex

battleroyalex
  • Members
  • Pip
  • Newbie
  • 6 posts

Posted 05 April 2006 - 03:19 PM

[!--quoteo(post=361958:date=Apr 5 2006, 11:10 AM:name=ToonMariner)--][div class=\'quotetop\']QUOTE(ToonMariner @ Apr 5 2006, 11:10 AM) View Post[/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.

#4 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 05 April 2006 - 03:29 PM

[a href=\"http://www.phpclasses.org/browse/package/951.html\" target=\"_blank\"]A bbcode class[/a].

#5 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 05 April 2006 - 05:31 PM

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.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users