Jump to content

HELP!!!


phpwiz

Recommended Posts

ok i have made a script with bbcodes and emoticons and it all works perfectly but i need a php code where it inserts the selected option into the text area.

what i mean to say is. on top of when u post a topic or reply on phpfreaks forum there are buttons and stuff that u can click and it enters the [][/] stuff for you i am trying to make this does anyone know how or can they teach me please because i need this ASAP!!!!!

Link to comment
Share on other sites

Ok i tried to get one to work and it didnt, here is the entire code

<?php session_start(); ?>
<script language="JavaScript">
var Editor;

function Format(action)
{
Editor.execCommand(action, false, null);
}

function Colour(colour)
{		
Editor.execCommand("forecolor",false, colour);
}

window.onload = function()
{
Editor = document.getElementById('textbox').contentWindow.document;
Editor.designMode = "on";
document.forms[0].onsubmit = function()
{
	var text = document.getElementById('text');
	text.value = Editor.body.innerHTML;
}
}

</script>

<?php


include "BBcode.php";

include "admin.php";

$connect = mysql_connect('localhost', 'root', '') or die("Couldnt connect");
  mysql_select_db('members') or die("Couldn't find db");

  $namecheck = mysql_query("SELECT username FROM users");
  $count = mysql_num_rows($namecheck);

if ($_SESSION['username'])
{

if ($_POST ['post'])
{

//get data
$title = $_POST ['title'];
$body = $_POST ['body'];
$date = $_POST ['date'];
$postee = $_SESSION['username'];
$avatar = $_POST ['avatar'];

//check for existance
if ($title&&$body&&$avatar)
{
$date = date ("Y-m-d");

//insert data
$insert = mysql_query("INSERT INTO news VALUES ('','$title','$body','$date','$postee','$avatar')") or die (mysql_error ());

echo "Your news has been posted! <a href='v_news.php'>News here.</a>";
}




else
{
echo "Please fill out title and body!<p>";
}
}
else
{
?>


<form action='p_news.php' method='POST'>
<table>
<tr>
<td>
<input type="button" onclick="Format('[b]TEXT HERE[/b]')" value="Bold" />
<input type="button" onclick="Format('[u]TEXT HERE[/u]')" value="Underline" />
<input type="button" onclick="Format('[i]TEXT HERE[/i]')" value="italics" />
<input type="button" onclick="Format('[s]TEXT HERE[/s]')" value="Strike" />
<input type="button" onclick="Format('[url=http://URL HERE]LINK[/u]')" value="Url" />
<input type="button" onclick="Format('[img=IMG LINK HERE]')" value="Img" />
<input type="button" onclick="Format('[color=blue]TEXT HERE[/color]')" value="Color" /> 
</td>
</tr>
</table>
<table>
<td>
Title:
</td>

<td>
<input type='text' name='title'><p>
</td>
</tr>
<tr>
<td>
Avatar:
</td>
<td>
<input type='text' name='avatar'><p>
</td>
</tr>
<tr>
<td>
Body:<br>
</td>
<td>
<iframe id="textbox" style="width:300px; height:150px"></iframe><br/>
</td>
</tr>
<tr>
<td>

</td>
<td>
<input type='submit' name='post' value='Post this news!'>
</td>
</tr>
</table>
</form>

<?php
}
}
else
die("Sorry you are not logged in <a href='login.php'> Click here</a> to login");

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.