Hello everyone,

I have been learning how to code a simple message board (or 'forum') and have really been proud of what Ive achieved so far.

However, I want to include these message boards in my online community but currently members will have to add their name as a field of the add topic page.

Instead I would like it to simply have a TITLE and MESSAGE field only and for it to automatically recognise my members as the sender.

I would also like to know how to code my message board so that a user who is above a certain rank (I have a $rank_check variable on each page) is able to delete messages.

I have tried to find a tutorial on this but only seem to find the basic one. Can any one help at all? Here is the code from the do_addtopic.php. I also have a add_topic.html but gues this is the one I need to look at?

I dont even now where to start with checking users identity ....is it using a FETCH command? Im very new to PHP and self teaching. lol But LOVE PHP to bits. Any help or advice would be much appreciated...

<?php

$rank_check = 3;
include "../../global.inc.php";

//check for required fields from the form
if ((!$_POST[topic_owner]) || (!$_POST[topic_title]) || (!$_POST[post_text])) {
	header("Location: addtopic.html");
	exit;
}

//connect to server and select database
$conn = mysql_connect("localhost", "NOT TELLING", "NOT TELLING") or 

die(mysql_error());
mysql_select_db("NOT TELLING",$conn)  or die(mysql_error());

//create and issue the first query
$add_topic = "insert into forum_topics values ('', '$_POST[topic_title]',now(), '$_POST[topic_owner]')";
mysql_query($add_topic,$conn) or die(mysql_error());

//get the id of the last query
$topic_id = mysql_insert_id();

//create and issue the second query
$add_post = "insert into forum_posts values ('', '$topic_id', '$_POST[post_text]', now(), '$_POST[topic_owner]')";
mysql_query($add_post,$conn) or die(mysql_error());

//create nice message for user
$display_block = "<P><center><font face=Verdana><body bgcolor=#CCCCFF>The <strong>$topic_title</strong> topic has been created.<p><br><P align=center style=margin-top: 0; margin-bottom: 0><a href=http://www.cyberpetworld.com/city%20mb/police/topiclist.php>Back 
to Message Board</a></font></p></p>";
?>
<html>
<head><p><br><br><p><center><font face=Verdana>
<title>New Topic Added</title>
</head>
<body><center><font face=Verdana>
<h1>New Topic Added</h1><p><br>
<?php echo $display_block; ?>
</body>
</html>

Here is the URL to one of my Message Boards: http://www.cyberpetworld.com/city%20mb/police/topiclist.php

Thank you for your time

Justin
http://cyberpetworld.com

Justin

Your first question would be answered with a user management system and the use of cookies and/or sessions.

The second [rank] is obvious.Include a column in the users table of your database and update it by one when a user adds a topic.And check it whenever you want it.

Take a look at:
http://www.tizag.com/
And tutorials of zend.com website

Ok thanks most,

Will look into cookies and sessions and see what I can find. My website obivously uses cookies already so im guessing that should make it easier.

I will try and add a column and do what you said. :>/ Heres hoping I can do it. :O)

Once again Thanks
Justin

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.