One of my first ever projects I embarked on when I began to understand PHP well was a forum system. I've decided to begin writing a tutorial to help people start one of their own. The code for this project is based on that of OakumBoard/cBoard, my own forum software which can be seen running at www.sonicxtremegm.co.cc
Anyways, time to start off, you must run this SQL query on an SQL database with a name of your choice:
CODE
s
CREATE TABLE `forums` (
`id` int(3) NOT NULL auto_increment,
`name` varchar(80) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=3;
INSERT INTO `forums` (`id`, `name`) VALUES
(1, 'Test Forum'),
CREATE TABLE `members` (
`id` int(4) NOT NULL auto_increment,
`username` varchar(65) NOT NULL default '',
`password` varchar(65) NOT NULL default '',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=3;
CREATE TABLE `replies` (
`topicid` int(4) NOT NULL,
`reply_id` int(4) NOT NULL,
`reply_user` varchar(50) NOT NULL,
`reply_text` longtext NOT NULL,
`reply_datetime` varchar(25) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
CREATE TABLE `topics` (
`id` tinyint(4) NOT NULL auto_increment,
`title` varchar(180) NOT NULL,
`text` longtext NOT NULL,
`datetime` varchar(30) NOT NULL default '0',
`user` varchar(80) NOT NULL,
`reply` int(4) NOT NULL,
`forumid` int(3) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=6;
CREATE TABLE `forums` (
`id` int(3) NOT NULL auto_increment,
`name` varchar(80) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=3;
INSERT INTO `forums` (`id`, `name`) VALUES
(1, 'Test Forum'),
CREATE TABLE `members` (
`id` int(4) NOT NULL auto_increment,
`username` varchar(65) NOT NULL default '',
`password` varchar(65) NOT NULL default '',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=3;
CREATE TABLE `replies` (
`topicid` int(4) NOT NULL,
`reply_id` int(4) NOT NULL,
`reply_user` varchar(50) NOT NULL,
`reply_text` longtext NOT NULL,
`reply_datetime` varchar(25) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
CREATE TABLE `topics` (
`id` tinyint(4) NOT NULL auto_increment,
`title` varchar(180) NOT NULL,
`text` longtext NOT NULL,
`datetime` varchar(30) NOT NULL default '0',
`user` varchar(80) NOT NULL,
`reply` int(4) NOT NULL,
`forumid` int(3) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=6;
Now, you create a file called conf.php. Inside it should be the text:
CODE
<?php
$host= "[b]localhost[/b]"; // Host name
$username="[b]admin[/b]"; // Mysql username
$password="[b]adminone[/b]"; // Mysql password
$db_name= "[b]admindb[/b]"; // Database name
mysql_connect("$host", "$username", "$password")or die("Failed to connect to DB server");
mysql_select_db("$db_name")or die("Failed to select DB");
?>
$host= "[b]localhost[/b]"; // Host name
$username="[b]admin[/b]"; // Mysql username
$password="[b]adminone[/b]"; // Mysql password
$db_name= "[b]admindb[/b]"; // Database name
mysql_connect("$host", "$username", "$password")or die("Failed to connect to DB server");
mysql_select_db("$db_name")or die("Failed to select DB");
?>
Replace the bolded areas with the appriate value for your data.

