hi all
I have CMS system with Mysql storage. in this system there are options to add news title, news subject, news theme and image upload features.
i would like to add PHP bbcode options to the theme section of this
code. for ex i need to write smth bold in news body section
here is my CMS
admin.page

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Bismillah</title>
<script type="text/JavaScript">
<!--
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
//-->
</script>
</head>

<body>
<p>
<? 
include("connect.php"); 

include ("image_set.php"); 
?>

</p>
<p style="font-size:24pt; color:#FF0000;">Xeber elave ele</p>

<hr />
Mesajlar :&nbsp;
<? 

$no=$_POST[no];
$title=$_POST[title];
$subject=$_POST[subject];
$description=$_POST[description];
$aktive=$_POST[aktive];
$search=$_POST[search];
$show=$_POST[show];
$category=$_POST[category];
// image ayarlari burada
$small_image="news_little"; //
$big_image="news_big"; // chmod 777
$big_image_width=640;
$big_image_height=480;
$little_image_width=200;
$little_image_height=150;
//if ($image)
?>
<?  if ($_POST[del])
{// del dugmesine badeldiysa
$query=mysql_query("select * from news where no='$no'");
while($row=mysql_fetch_row($query))
	/
{ @unlink($row[4]); 
  @unlink($row[5]); 
	}
if (mysql_query("delete from news where no='$no'")) echo "image deleted";
else echo "not deleted";
}
?>
<? 
if ($_POST[edit])
{

$query=mysql_query("select * from news where no='$no'");
	while($row=mysql_fetch_row($query))
	{ 
	$no2=$row[0];
	$title2=$row[1];
	$subject2=$row[2];
	$description2=$row[3];
	$littleimage2=$row[4];
	$image2=$row[5];
	$aktive2=$row[7];
	}
}
?>
<? if($_POST["add"])
{ 
if(strlen($_FILES["image"]["name"])>4)
		{
		  
		  
		$find=$_FILES["image"] ;
		$to_be_finded = array('з','З','э','Э','р','Р','ь','ц','Ю','ю','Ц','Ь',',',' ','(',')','[',']'); 
		$to_be_changed  = array('c','C','i','I','g','G','u','o','S','s','O','U','','_','','','',''); 
		$_FILES["image"]=str_replace($to_be_finded, $to_be_changed, $find);
		$image = "$big_image/".$_FILES["image"]["name"]; 	   
		move_uploaded_file($_FILES["image"]["tmp_name"],$image);
		$littleimage  = "$small_image/".$_FILES["image"]["name"];  
		move_uploaded_file($_FILES["image"]["tmp_name"],$littleimage);
		
		$icerik = resample($image,$little_image_en,$little_image_boy); 
		$folder  = fopen ($littleimage,"w+"); 
				   fwrite($folder,$icerik); 
				   fclose($folder); 
				   
		
		$icerik = resample($image,$big_image_en,$big_image_boy); 
		$folder  = fopen ($image,"w+"); 
				   fwrite($folder,$icerik); 
				   fclose($folder); 
		
		}


if (!$no)
	{
		
	if (mysql_query("insert into news values ('','$title','$subject','$description','$littleimage','$image','$aktive', '$category')"))
	{echo " cahnged"; $image="";$littleimage="";}
	else echo "not changed!";
	
	}
else 
{ 
	if ($image) $imageek="image='$image',littleimage='$littleimage'";
	if (mysql_query("update  news set title='$title',subject='$subject',description='$description',aktive='$aktive'$imageek where no='$no'"))
	{echo "news added"; $image="";$littleimage="";}
	else echo "news not added";
	}
}
?>
<hr />

<form id="form1" name="form1" method="post" action="">
  available news:
  <label>
  <select name="no" id="no">
  <?
  $query=mysql_query("select * from news order by no desc");
while($row=mysql_fetch_row($query))
{
echo "<option value='$row[0]'>$row[1]</option>";
}
  ?>
    
  </select>





  <label>
  <input name="edit" type="submit" id="edit" value="Dьzenle" />
  </label>
  <label>
  <input name="del" type="submit" id="del"  value="Sil" />
  </label>
  <label></label>
</form>
<hr />
  
<form id="form2" name="form2" method="post" action=""   enctype="multipart/form-data">
  <table width="250" border="1" cellspacing="5" cellpadding="0">
    <tr>
      <td width="80">no 
      <input name="no" type="hidden" value="<? echo $no2; ?>" /></td>
  
      <td width="100"><label></label>	  </td>
    </tr>
    <tr>
      <td>Image
 <? if($littleimage2)
 
{echo "<img src=$littleimage2 align=right><br />";
//echo "<input name='littleimage' type='hidden' id='littleimage' value='$littleimage2' />";
}
?>
</td>
      <td>   <label>
      <input name="image" type="file" id="image" />
      </label></td>
    </tr>
    <tr>
      <td>Title</td>
      <td><input name="title" type="text" id="title" value="<? echo $title2;?>" size="50" /></td>
    </tr>
    <tr>
      <td>Subject</td>
      <td><input name="subject" type="text" id="subject" value="<? echo $subject2;?>" size="50" /></td>
    </tr>
    <tr>
      <td>description</td>
      <td><label>
        <textarea name="description" cols="80" rows="5" id="is"><? echo $description2;?></textarea>
      </label></td>
    </tr>
    <tr>
      <td>Aktiv</td>
      <td><label>
        <input <?php if ($aktive2=="aktive") {echo "checked=\"checked\"";} ?>  name="aktive" type="radio" value="aktive" checked="checked" />
      aktivate
      <input <?php if ($aktive2=="pasif") {echo "checked=\"checked\"";} ?>  name="aktive" type="radio" value="pasif" />
      do it passive</label></td>
    </tr>
    <tr>
      <td><select name="category">
	    <option value=default>birini sec</option>
<option value="PHP">PHP</option>
<option value="JavaScript">JavaScript</option>
<option value="CSS">CSS</option>
<option value="Photoshop">Photoshop</option>
<option value="HTML">HTML</option>
</select>
	
	
      </td>
      <td><input name="add" type="submit" id="add" value="daxil et" />
        <label>
        <input name="search" type="submit" id="axtar" value="Axtar" />
        <input name="show" type="submit" id="show" value="Butun xeberleri show" />
        </label></td>
    </tr>
  </table>
</form>

<p>&nbsp;</p>
<? 
if (($search) || ($show))
{
if ($search)
{
if ($title) $query=mysql_query("select * from news where title like '%$title%'");
if ($subject) $query=mysql_query("select * from news where subject like '%$subject%'");
if ($description) $query=mysql_query("select * from news where description like '%$description%'");
}
 if ($show)
{
$query=mysql_query("select * from news order by no desc");
}
echo "<table border=1>
<tr>
<td>Dьzenle</td>
<td>Sil</td>
<td>No</td>
<td>title</td>
<td>subject</td>
<td>description</td>
<td>littleimage</td>
<td>aktive</td>
</tr>";
while($row=mysql_fetch_row($query))
{echo "
<tr><form action=\"\" method=\"post\"><input name=\"no\" type=\"hidden\" value=\"$row[0]\">

<td><input name=\"edit\" type=\"submit\" value=\"deyish\">	</td>
<td><input name=\"del\" type=\"submit\" value=\"Sil\"></td>

<td>$row[0]&nbsp;</td>
<td>$row[1]&nbsp;</td>
<td>$row[2]&nbsp;</td>
<td>$row[3]&nbsp;</td>
<td><img src=$row[4]>&nbsp;</td>
<td>$row[6]</td>
</form>	</tr>";
}
echo "</table>";
}
?>
<?php
echo "<a href=\"http://aziko.6te.net\">go the main page</a>";
?>
</body>
</html>

and image_set.php

<?php
  function resample($image,$max_width,$max_height) 
     { 

     
     ob_start(); 

   
     $im = getimagesize($image); 
     $width    = $im[0]; 
     $height   = $im[1]; 


     $x_ratio = $max_width  / $width; 
     $y_ratio = $max_height / $height; 

     if (($width <= $max_width) and ($height <= $max_height)){ 
        $son_width  = $width; 
        $son_height = $height; 
        } 
     else if (($x_aratio * $height) < $max_height){ 
        $son_width  = $max_width; 
        $son_height = ceil($x_ratio * $height); 
        } 
     else { 
        $son_width  = ceil($y_ratio * $width); 
        $son_height = $max_height; 
        } 

  
     $old = imagecreatefromjpeg($image); 
     $new = imagecreatetruecolor($son_width,$son_height); 

    
     imagecopyresampled( 
        $new,$eski,0,0,0,0, 
        $son_width,$son_height,$width,$height); 

    
     imagejpeg($new,null,-1); 
     $icerik = ob_get_contents(); 

    
     ob_widthd_clean(); 
     imagedestroy($old); 
     imagedestroy($new); 

     return $icerik; 

 }
?>

and finally
index.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Dahi Tasarim . CoM</title>
<style type="text/css">
<!--
a:link {
	color: #0066FF;
	text-decoration: underline;
}
a:visited {
	text-decoration: underline;
	color: #0033CC;
}
a:hover {
	text-decoration: none;
	color: #FFFFFF;
}
a:active {
	text-decoration: underline;
}
-->
</style></head>

<body><center>

<? // baglan php yi yukluyoruz
include("connect.php"); 
define('MAX_PAGE1', 4);
define('MAX_PAGE2', 1);
/
$no=$_GET["no"];

$page = $_GET["page"]; 
$start1 = MAX_PAGE1 * ($page - 1);
$max2 = MAX_PAGE2;
list($total) = mysql_fetch_row($rs1);
$page_amount = ceil($total / MAX_PAGE1);
if (0 == $page){
$page = 1;
    }    
$start = MAX_PAGE1 * ($page - 1);
$max1 = MAX_PAGE1;
$rs1 = mysql_query("SELECT COUNT(aktive) FROM news") or die("Count query error!");
if (!$no && !$page)
{$query=mysql_query("select * from news where aktive='aktive' order by no desc limit 1");
}
if ($page && !$no) {
$query = mysql_query("SELECT * FROM news where aktive='aktive' ORDER BY no DESC LIMIT $start, $max2") or die("Employee query error!");
}
if ($no)/
{$query=mysql_query("select * from news where no='$no'");
}
while($row=mysql_fetch_row($query))
{
$title=$row[1];
$subject=$row[2];
$theme=$row[3];
$littleimage=$row[4];
$bigimage=$row[5];
$theme=str_replace ("\n","<br />",$theme);

}
?>
<table border="1" cellpadding="10" cellspacing="10" bordercolor="#666666" bgcolor="#CCCCCC">
  <tr>
    <td width="500" valign="top" bgcolor="#FFCC00" name="bigimage">
	<?php if ( !empty( $bigimage ) ): ?>
	<img alt="" src="<?=$bigimage; ?>">
<?php else: ?>
<img alt="No image" src="/yukle/news_buyuk/noimage.jpeg">
<?php endif; ?>
<div class="indent1">
<h1><?=$title; ?> <span></span></h1>
<p><?=$theme; ?></p></td>
<td width="170" valign="top" bgcolor="#FF9900">
<?


define('MAX_PAGE', 4);
$db = mysql_connect("localhost", "username", "password") or die("Couldn't connect to db!");
mysql_select_db("username") or die("Couldn't select db!");
$rs = mysql_query("SELECT COUNT(aktive) FROM news") or die("Count query error!");
list($total) = mysql_fetch_row($rs);
$page_amount = ceil($total / MAX_PAGE);
$page = intval(@$_GET["page"]);     
if (0 == $page){
$page = 1;
}    
$start = MAX_PAGE * ($page - 1);
$max = MAX_PAGE;
$rs = mysql_query("SELECT no, littleimage, subject, description, title FROM news where aktive='aktive' ORDER BY no 
DESC LIMIT $start, $max") or die("Employee query error!");
?>
<?php

while($row1=mysql_fetch_row($rs))
{
$no=$row1[0];
$subject=$row1[2];
$description=$row1[3];
$littleimage=$row1[1];
$title=$row1[4];
?>
<?php
if(file_exists($littleimage)){
echo "<p><a href='index.php?page=$page&no=$no'>
<img alt='' src='$littleimage' />
<br><span>$title</span></a><br />$subject
</p>";
}
else
{
echo "<p><a href='index.php?page=$page&no=$no'>
<img alt='' src='/yukle/news_buyuk/noimage.jpeg' />
<br><span>$title</span></a><br />$subject
</p>";
}
}

?>
</td></tr>
  <tr>
    <td colspan="2" bgcolor="#669933" align="left"><ul>
     <?
$query=mysql_query("select * from news where aktive='aktive' order by no desc limit 0,20");
// newslerin sadece titlelarini ekranda gosterip link verecegiz
while($row=mysql_fetch_row($query))
{
$no=$row[0];
$title=$row[1];
echo "<li> <a href=index.php?no=$no>$title</a></li>";
}
?>
</ul></td></tr>
</table>
<table border="0" cellpadding="5" align="center">
 <tr><td>Istedigin pageye get:</td>
<?php
for ($i = 1; $i < $page_amount; $i++) {
$txt = $i;
if ($page != $i)
$txt = "<a href=\"" . $_SERVER["PHP_SELF"] . "?page=$i\">$txt</a>";
?>      
<td align="center"><?= $txt ?></td>
<?php
  }
?>
</tr>
</table></center>
<hr>
</div>
<? 
if ($query) mysql_free_result($query);
if ($rs)  mysql_free_result($rs);
if ($connect) mysql_close($connect); 
?>
</body>
</html>

If you want somebody to embed bbcode for you then I don't think many people will offer unless you put some effort into it. I have read that there is a bbcode library or alternatively if that library isn't available on your webhost then you can use the recourse hungry regex.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.