BBCode - How to?
Posted: Fri Oct 18, 2013 7:41 am
how can iapply the bbcode at my script this is wat ive done...
<?php
include 'core/init.php';
include 'texteditor.php';
if (isset($_POST['user'], $_POST['title'], $_POST['body'], $_POST['cid'])){
if (empty($_POST['user'])){
$errors[] = "Please Enter Your Valid Username.";
}
if (empty($_POST['title'])){
$errors[] = "Your Title cannot be empty.";
}
if (empty($_POST['cid'])){
$errors[] = "Please Enter Your Category.";
}
if (empty($_POST['body'])){
$errors[] = "Your Topic Cannot be empty.";
}
if (empty($errors)){
add_post($_POST['user'], $_POST['title'], $_POST['body'], $_POST['cid']);
header('Location: admin.php');
die();
}
}
?>
<?php include 'includes/overall/header.php'; ?>
<div id="post-topic">
<?php
if (empty($errors) === false){
echo error_box($errors);
}
?>
<form action="" method="post">
<p>
<label>Name</label>
<input type="text" name="user" id="user">
</p>
<p>
<label>Title</label>
<input type="text" name="title" id="title">
</p>
<p>
<label>Category</label>
<select name="cid"><option value='0'>Please Choose</option>
<?php
$cat_post = get_cat();
foreach ($cat_post as $cat){
?>
<option value="<?php echo $cat['cat_id']; ?>"> <?php echo $cat['cat']; ?></option>
<?php
}
echo "</select>";
?>
</p>
<p>
<a href="javascript:void(0);" onclick="document.getElementById('body').value += '[\b][\/b]'">Bold</a>
<textarea cols="100" name="body" id="body" rows="20"></textarea>
</p>
<p>
<input type="submit" value="Add Post">
</p>
</form>
</div>
<?php include 'includes/overall/footer.php'; ?>