DidNotCompute
Members-
Posts
47 -
Joined
-
Last visited
Content Type
Profiles
Forums
Events
Everything posted by DidNotCompute
-
This is my fully automated competition system. It allows you to create competitions for users so they are able to compete with each other for the top 3 prizes. Features Create competition from the control panel - currently crimes and jail busts (names can be edited to suit your game genre). Cancel competition at anytime from the control panel Users can choose to enter a competition Top 10 competitors list Prizes for the top 3 competitors SQL ALTER TABLE `users` ADD `crimes` INT(11) NOT NULL DEFAULT '0' , ADD `jail_busts` INT(11) NOT NULL DEFAULT '0' , ADD `competition` ENUM('0','1') NOT NULL DEFAULT '0' , ADD `competition_starting` INT(11) NOT NULL DEFAULT '0' ; INSERT INTO `settings` (`conf_id`, `conf_name`, `conf_value`) VALUES (NULL, 'competition', 'Inactive'), (NULL, 'competition_type', ''), (NULL, 'competition_prize_1', ''), (NULL, 'competition_prize_2', ''), (NULL, 'competition_prize_3', ''); competition.php <?php /* * Competition System * Free Modification * DidNotCompute - http://makewebgames.io/member.php/70333-DidNotCompute */ include "globals.php"; if ($ir['user_level'] == 2) { echo "<br /><a href='competition_control.php'><u>Click to access Competition Control Panel</u></a>"; } if ($set['competition_type'] == "Crimes") { $type = "crimes"; } elseif ($set['competition_type'] == "Jail Busts") { $type = "jail_busts"; } echo "<h2>Competition</h2>"; if (isset($_POST['enter'])) { if ($set['competition'] == "Inactive") { echo "There are currently no active competitions!"; } else { if ($ir['competition'] == 1) { echo "You are already entered in this competition!"; } else { $db->query("UPDATE users SET competition='1', competition_starting='$ir[$type]' WHERE userid='$userid'"); echo "You have successfully entered the competition!"; }} } $color = $set['competition'] == "Inactive" ? "FF0000" : "32CD32"; echo "<table width='70%' class='table' cellspacing='1'> <tr> <th>Status: <span style='color: #$color'>{$set['competition']}</span></th> </tr> <tr> <td>"; if ($set['competition'] == "Inactive") { echo "<div align='center' style='font-weight: bold;'>There is currently no active competition. Check back soon!</div>"; } else { echo "<div align='center' style='font-weight: bold;'>{$set['competition_type']} Competition</div>"; if ($set['competition_type'] == "Crimes") { echo "<div align='center'>The aim of the competition is to commit as many crimes as possible. The prizes for the top 3 users are:</div>"; } elseif ($set['competition_type'] == "Jail Busts") { echo "<div align='center'>The aim of the competition is to do as many jail busts as possible. The prizes for the top 3 users are:</div>"; } echo "<div align='center'>1. ".(money_formatter($set['competition_prize_1']))."</div>"; echo "<div align='center'>2. ".(money_formatter($set['competition_prize_2']))."</div>"; echo "<div align='center'>3. ".(money_formatter($set['competition_prize_3']))."</div>"; if ($ir['competition'] == 0) { echo "<div align='center'><form method='post'><input type='submit' name='enter' class='button' value='Enter Competition' /></form></div>"; } else { $current = $ir[$type] - $ir['competition_starting']; echo "<div align='center' style='font-weight: bold;'>{$set['competition_type']}: $current</div>"; } } echo "</td> </tr> </table>"; if ($set['competition'] == "Active") { echo "<h3>Top 10</h3>"; echo "<table width='50%' class='table' cellspacing='1'> <tr> <th>#</th> <th>Username</th> <th>{$set['competition_type']}</th> </tr>"; $get_top10 = $db->query("SELECT userid, username, $type, competition_starting FROM users WHERE competition='1' ORDER BY $type-competition_starting DESC LIMIT 10"); $n = 1; while ($top10 = mysql_fetch_object($get_top10)) { $value = $top10->$type - $top10->competition_starting; echo "<tr> <td>$n</td> <td><a href='viewuser.php?u=$top10->userid'>$top10->username</a></td> <td>$value</td> </tr>"; $n++; } echo "</table>"; } $h->endpage(); ?> competition_control.php <?php /* * Competition System * Free Modification * DidNotCompute - http://makewebgames.io/member.php/70333-DidNotCompute */ include "globals.php"; if ($ir['user_level'] != 2) { exit("You do not have permission to view this page"); } if ($set['competition'] == "Active") { echo "<h3>Cancel Competition</h3>"; echo "There is currently a {$set['competition_type']} competition in progress. If you want to cancel this competition then <a href='?cancel=true' style='font-weight: bold;'>click here</a>."; } else { echo "<h3>Create Competition</h3>"; echo "<form method='post'> <div>Type: <select name='type'><option value='Crimes'>Crimes</option><option value='Jail Busts'>Jail Busts</option></select></div> <div>1st Place Prize: <input type='text' name='first_prize' /></div> <div>2nd Place Prize: <input type='text' name='second_prize' /></div> <div>3rd Place Prize: <input type='text' name='third_prize' /></div> <div><input type='submit' name='create_competition' class='button' value='Create Competition' /></div> </form>"; } if (isset($_GET['cancel'])) { $db->query("UPDATE users SET competition='0' WHERE competition='1'"); $db->query("UPDATE settings SET conf_value='Inactive' WHERE conf_name='competition'"); $db->query("UPDATE settings SET conf_value='' WHERE conf_name='competition_type'"); $db->query("UPDATE settings SET conf_value='' WHERE conf_name='competition_prize_1'"); $db->query("UPDATE settings SET conf_value='' WHERE conf_name='competition_prize_2'"); $db->query("UPDATE settings SET conf_value='' WHERE conf_name='competition_prize_3'"); echo "The competition has been cancelled!"; } if (isset($_POST['create_competition'])) { $type = htmlspecialchars($_POST['type']); $prize1 = abs(intval($_POST['first_prize'])); $prize2 = abs(intval($_POST['second_prize'])); $prize3 = abs(intval($_POST['third_prize'])); $valid_type = array("Crimes", "Jail Busts"); if (!in_array($type, $valid_type)) { echo "The competition type you selected is invalid!"; } else { if (!$prize1 || !$prize2 || !$prize3) { echo "You must fill in all prize fields!"; } else { $db->query("UPDATE settings SET conf_value='Active' WHERE conf_name='competition'"); $db->query("UPDATE settings SET conf_value='$type' WHERE conf_name='competition_type'"); $db->query("UPDATE settings SET conf_value='$prize1' WHERE conf_name='competition_prize_1'"); $db->query("UPDATE settings SET conf_value='$prize2' WHERE conf_name='competition_prize_2'"); $db->query("UPDATE settings SET conf_value='$prize3' WHERE conf_name='competition_prize_3'"); echo "The competition has been successfully created!"; }} } $h->endpage(); ?> competition_cron.php (Set the cron for once a day or once a week, or however long you'd like competitions to last) <?php /* * Competition System * Free Modification * DidNotCompute - http://makewebgames.io/member.php/70333-DidNotCompute */ include "config.php"; global $_CONFIG; define("MONO_ON", 1); require "class/class_db_{$_CONFIG['driver']}.php"; $db=new database; $db->configure($_CONFIG['hostname'], $_CONFIG['username'], $_CONFIG['password'], $_CONFIG['database'], $_CONFIG['persistent']); $db->connect(); $set = array(); $settq = $db->query("SELECT * FROM settings"); while($r=$db->fetch_row($settq)) { $set[$r['conf_name']]=$r['conf_value']; } if ($set['competition'] == "Active") { if ($set['competition_type'] == "Crimes") { $type = "crimes"; } elseif ($set['competition_type'] == "Jail Busts") { $type = "jail_busts"; } $get_top3 = $db->query("SELECT userid, $type, competition_starting FROM users WHERE competition='1' ORDER BY $type-competition_starting DESC LIMIT 3"); $n = 1; while ($top3 = mysql_fetch_object($get_top3)) { switch ($n) { case 1: $prize = $set['competition_prize_1']; break; case 2: $prize = $set['competition_prize_2']; break; case 3: $prize = $set['competition_prize_3']; break; } $db->query("UPDATE users SET money=money+$prize WHERE userid='$top3->userid'"); $n++; } $db->query("UPDATE users SET competition='0' WHERE competition='1'"); $db->query("UPDATE settings SET conf_value='Inactive' WHERE conf_name='competition'"); $db->query("UPDATE settings SET conf_value='' WHERE conf_name='competition_type'"); $db->query("UPDATE settings SET conf_value='' WHERE conf_name='competition_prize_1'"); $db->query("UPDATE settings SET conf_value='' WHERE conf_name='competition_prize_2'"); $db->query("UPDATE settings SET conf_value='' WHERE conf_name='competition_prize_3'"); } ?> In docrime.php replace line 31 with mysql_query("UPDATE users SET money={$ir['money']}, crystals={$ir['crystals']}, exp={$ir['exp']}, crimexp=crimexp+{$r['crimeXP']}, crimes=crimes+1 WHERE userid=$userid"); In jailbust.php replace line 28 with $db->query("UPDATE users SET crimexp=crimexp+{$gain}, jail_busts=jail_busts+1 WHERE userid=$userid");
-
I can understand using it for the register/login and referral. However, I wouldn't want too much social media integration in a game; it might feel a little intrusive.
-
mccode-v2 Users online basic update
DidNotCompute replied to JamesRage's topic in Free Modifications
$time = abs(intval($_GET['time'])); -
Thanks for the comment. :)
-
This is the lottery system I have created. It is fully customizable as it allows you to change the price of tickets, how often you want lottery draws to take place and the amount of numbers that users can choose from. Features 5 number lottery. Users can buy multiple tickets. Edit the cost of tickets. Edit the amount of numbers that users can choose from. Edit how often you want the lottery draw to take place. SQL CREATE TABLE IF NOT EXISTS `lottery_tickets` ( `id` int(100) NOT NULL AUTO_INCREMENT, `userid` int(100) NOT NULL, `numbers` varchar(100) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; INSERT INTO `settings` (`conf_id`, `conf_name`, `conf_value`) VALUES (NULL, '', ''), (NULL, 'lottery_days', '1'); INSERT INTO `settings` (`conf_id`, `conf_name`, `conf_value`) VALUES (NULL, '', ''), (NULL, 'lottery_ticketcost', '1000'); INSERT INTO `settings` (`conf_id`, `conf_name`, `conf_value`) VALUES (NULL, '', ''), (NULL, 'lottery_numbers', '20'); lottery.php <?php /* * Lottery System * Free Modification * DidNotCompute - http://makewebgames.io/member.php/70333-DidNotCompute */ include "globals.php"; if($ir['user_level'] == 2) { echo '<br /><a href="lottery_control.php"><u>Click to access Lottery Control Panel</u></a>'; } $get_tickets_total = $db->query("SELECT COUNT(*) FROM lottery_tickets"); $total = mysql_fetch_array($get_tickets_total); $jackpot = $set['lottery_ticketcost']*$total[0]; echo '<h2>Lottery</h2>'; echo "The lottery draw takes place once every {$set['lottery_days']} days.<br />"; echo "<b>Current Jackpot: \${$jackpot}</b><br />"; echo '<h3>Buy Ticket</h3>'; echo "Each ticket costs \${$set['lottery_ticketcost']}. You must pick 5 different numbers.<br />"; echo '<form method="post"> <table width="60%"> <tr align="center">'; $n = 1; while ($n <= 5) { echo '<td><select name="number_'; echo $n.'">'; $i = 1; while ($i <= $set['lottery_numbers']) { echo '<option value="'; echo $i.'">'; echo $i.'</option>'; $i++; } echo '</select></td>'; $n++; } echo '</tr> <tr align="center"> <td colspan="5"><input type="submit" name="buy_ticket" value="Buy Ticket" /></td> </tr> </table> </form>'; if(isset($_POST['buy_ticket'])) { $number_1 = abs(intval($_POST['number_1'])); $number_2 = abs(intval($_POST['number_2'])); $number_3 = abs(intval($_POST['number_3'])); $number_4 = abs(intval($_POST['number_4'])); $number_5 = abs(intval($_POST['number_5'])); $numbers = array($number_1, $number_2, $number_3, $number_4, $number_5); if(array_unique($numbers) != $numbers) { echo "You must pick 5 different numbers!"; } else { if($ir['money'] < $set['lottery_ticketcost']) { echo "You need \${$set['lottery_ticketcost']}!"; } else { $numbers_implode = implode("-", $numbers); $db->query("INSERT INTO lottery_tickets VALUES ('', {$ir['userid']}, '{$numbers_implode}')"); $db->query("UPDATE users SET money=money-{$set['lottery_ticketcost']} WHERE userid={$ir['userid']}"); echo "You have successfully purchased the ticket ($numbers_implode)."; }} } echo '<h3>Your Tickets</h3>'; echo 'You have purchased the following tickets for the next lottery draw.<br />'; echo '<table width="50%" class="table" cellspacing="1"> <tr> <th>Ticked ID</th> <th>Numbers</th> </tr>'; $tickets = $db->query("SELECT * FROM lottery_tickets WHERE userid={$ir['userid']} ORDER BY id DESC"); while ($ticket = mysql_fetch_object($tickets)) { echo "<tr> <td>$ticket->id</td> <td>$ticket->numbers</td> </tr>"; } echo '</table>'; $h->endpage(); ?> lottery_control.php <?php /* * Lottery System * Free Modification * DidNotCompute - http://makewebgames.io/member.php/70333-DidNotCompute */ include "globals.php"; if($ir['user_level'] != 2) { exit("You do not have permission to view this page!"); } echo '<h2>Lottery Control Panel</h2>'; echo '<form method="post">'; echo '<h3>Lottery Days</h3>'; echo 'Select how often (days) you want the lottery draw to take place. NOTE: You will need to update the cron job.<br />'; echo "<b>The current setting is: {$set['lottery_days']} days.</b><br />"; echo '<select name="days"><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option></select>'; echo '<h3>Lottery Numbers</h3>'; echo 'Select the amount of numbers you want users to be able to choose from.<br />'; echo "<b>The current setting is: {$set['lottery_numbers']} numbers.</b><br />"; echo "<input type='text' name='numbers' size='2' maxlength='2' value='{$set['lottery_numbers']}' />"; echo '<h3>Ticket Cost</h3>'; echo 'Select the cost per lottery ticket.<br />'; echo "<b>The current setting is: \${$set['lottery_ticketcost']}.</b><br />"; echo "$<input type='text' name='cost' value='{$set['lottery_ticketcost']}' />"; echo '<br /><br /><input type="submit" name="update" value="Update" />'; echo '</form>'; if(isset($_POST['update'])) { $days = abs(intval($_POST['days'])); $numbers = abs(intval($_POST['numbers'])); $cost = abs(intval($_POST['cost'])); if ($days > 7) { echo 'The days must be 7 or less!'; } else { if ($numbers < 6 || $numbers > 99) { echo 'The numbers must be greater than 5 and less than 100!'; } else { $db->query("UPDATE settings SET conf_value=$days WHERE conf_name='lottery_days'"); $db->query("UPDATE settings SET conf_value=$numbers WHERE conf_name='lottery_numbers'"); $db->query("UPDATE settings SET conf_value=$cost WHERE conf_name='lottery_ticketcost'"); echo 'Successfully updated!'; }} } $h->endpage(); ?> lottery_cron.php (I added comments to this so it is simpler to understand the logic) <?php /* * Lottery System * Free Modification * DidNotCompute - http://makewebgames.io/member.php/70333-DidNotCompute */ include "config.php"; global $_CONFIG; define("MONO_ON", 1); require "class/class_db_{$_CONFIG['driver']}.php"; $db=new database; $db->configure($_CONFIG['hostname'], $_CONFIG['username'], $_CONFIG['password'], $_CONFIG['database'], $_CONFIG['persistent']); $db->connect(); $set = array(); $settq = $db->query("SELECT * FROM settings"); while($r=$db->fetch_row($settq)) { $set[$r['conf_name']]=$r['conf_value']; } // Get Jackpot $get_tickets_total = $db->query("SELECT COUNT(*) FROM lottery_tickets"); $total = mysql_fetch_array($get_tickets_total); $jackpot = $set['lottery_ticketcost']*$total[0]; // Assign winning numbers $number_rand_1 = mt_rand(1, $set['lottery_numbers']); $number_rand_2 = mt_rand(1, $set['lottery_numbers']); $number_rand_3 = mt_rand(1, $set['lottery_numbers']); $number_rand_4 = mt_rand(1, $set['lottery_numbers']); $number_rand_5 = mt_rand(1, $set['lottery_numbers']); // Assign winning numbers in order (smallest to largest) $numbers_rand = array($number_rand_1, $number_rand_2, $number_rand_3, $number_rand_4, $number_rand_5); sort($numbers_rand, SORT_NUMERIC); // Check for winning tickets $get_tickets = $db->query("SELECT * FROM lottery_tickets"); while ($tickets = mysql_fetch_object($get_tickets)) { $numbers = explode("-", $tickets->numbers); sort($numbers, SORT_NUMERIC); // Assign ticket numbers in order (smallest to largest) so they can be checked with winning numbers if($numbers_rand == $numbers) { // Check ticket numbers equal winning numbers $db->query("UPDATE users SET money=money+$jackpot WHERE userid=$tickets->userid"); // Payout to winning user } } $db->query("TRUNCATE lottery_tickets"); // Delete all tickets ?> NOTE: It looks like the <br /> tags have been removed; however, just insert them where line breaks are required.
-
I'm creating a lottery system with a somewhat similar logic to yours (although yours is difficult to decipher...). Anyway, I will be releasing it for free so you'd be welcome to use it. :)
-
No problem and I don't need payment for this - it was quick. ;)
-
Here you go, I did this quickly but it works. SQL ALTER TABLE `users` ADD `signature` LONGTEXT NOT NULL ; In viewuser.php before include "globals.php"; add class bbcode { var $engine=""; function bbcode() { require "bbcode_engine.php"; $this->engine= new bbcode_engine; $this->engine->cust_tag("/</","<"); $this->engine->cust_tag("/>/",">"); //Since \n and <br> screw up preg, convert them out. $this->engine->cust_tag("/\n/","&nbrlb;"); $this->engine->simple_bbcode_tag("b"); $this->engine->simple_bbcode_tag("i"); $this->engine->simple_bbcode_tag("u"); $this->engine->simple_bbcode_tag("s"); $this->engine->simple_bbcode_tag("sub"); $this->engine->simple_bbcode_tag("sup"); $this->engine->simple_bbcode_tag("big"); $this->engine->simple_bbcode_tag("small"); $this->engine->adv_bbcode_tag("list","ul"); $this->engine->adv_bbcode_tag("olist","ol"); $this->engine->adv_bbcode_tag("item","li"); $this->engine->adv_option_tag("font","font","family"); $this->engine->adv_option_tag("size","font","size"); $this->engine->adv_option_tag("url","a","href"); $this->engine->adv_option_tag("color","font","color"); $this->engine->adv_option_tag("style","span","style"); $this->engine->simp_option_notext("img","src"); $this->engine->simp_bbcode_att("img","src"); $this->engine->cust_tag("/\(c\)/","©"); $this->engine->cust_tag("/\(tm\)/",""); $this->engine->cust_tag("/\(r\)/","®"); $this->engine->adv_option_tag_em("email","a","href"); $this->engine->adv_bbcode_att_em("email","a","href"); $this->engine->cust_tag("/\[left\](.+?)\[\/left\]/","<div align='left'>\\1</div>"); $this->engine->cust_tag("/\[center\](.+?)\[\/center\]/","<div align='center'>\\1</div>"); $this->engine->cust_tag("/\[right\](.+?)\[\/right\]/","<div align='right'>\\1</div>"); $this->engine->cust_tag("/\[quote name='(.+?)\'](.+?)\[\/quote\]/","<div class='quotetop'>QUOTE(\\1)</div><div class='quotemain'>\\2</div>"); $this->engine->cust_tag("/\[quote\](.+?)\[\/quote\]/","<div class='quotetop'>QUOTE</div><div class='quotemain'>\\1</div>"); $this->engine->cust_tag("/\[code\](.+?)\[\/code\]/","<div class='codetop'>CODE</div><div class='codemain'><code>\\1</code></div>"); $this->engine->cust_tag("/\[codebox\](.+?)\[\/codebox\]/","<div class='codetop'>CODE</div><div class='codemain' style='height:200px;white-space:pre;overflow:auto'>\\1</div>"); $this->engine->cust_tag("/&nbrlb;/","<br />\n"); } function bbcode_parse($html) { return $this->engine->parse_bbcode($html); } } In viewuser.php add this to where you want to display signatures $bbc = new bbcode; if(!$r['signature']) { $signature = "This user does not have a profile signature."; } else { $signature = $bbc->bbcode_parse($r['signature']); } echo "$signature"; In preferences.php add this to the menu <a href='preferences.php?action=signaturechange'>Signature Change</a><br /> In preferences.php add this to the switch statement case 'signaturechange': signature_change(); break; case 'signaturechange2': signature_change2(); break; In preferences.php add function signature_change() { global $ir,$c,$userid,$h; print "<h3>Signature Change</h3> Update your profile signature.<br /> <form action='preferences.php?action=signaturechange2' method='post'> Signature: <textarea rows=10 cols=50 name='signature'>{$ir['signature']}</textarea><br /> <input type='submit' value='Change Signature' /></form>"; } function signature_change2() { global $db,$ir,$c,$userid,$h; $signature = htmlspecialchars($_POST['signature']); $db->query("UPDATE users SET signature='$signature' WHERE userid=$userid"); print "Signature changed!"; }
-
Fetch the data from the query.
-
Sounds like "Missions" which many games have. However, best of luck with it!
-
I don't see a company registration number? Even though it claims to be a company at the bottom of the page. The address "B. Palace, Buckingham Palace Road, London, LN3 2RP" obviously isn't correct. Clearly something is awry.
-
More than one person can pre-order a domain; just because you have pre-ordered it doesn't guarantee it will be yours. You can even pay more to get higher priority in the pre-order phase.
-
This won't take into account variables in the URL.
-
If you want fonts then why not just go to http://www.google.com/fonts ?
-
Here's a Users Online mod I made for the Panther script. SQL ALTER TABLE `users` ADD `last_online` INT( 10 ) NOT NULL ; Add this to the end of mods/globals.php $current_time = time(); $db->query("UPDATE `users` SET `last_online` = $current_time WHERE `id` = $uid"); In the "mods" directory add the folder "users_online" and create the main.php file <?php include_once('mods/globals.php'); if (array_key_exists('option', $_GET)) { $option = abs(intval($_GET['option'])); $valid_options = array("1", "2", "3", "4"); if(!in_array($option, $valid_options)){ $time_minus = "600"; echo '<div class="alert alert-error">Select a valid option!</div>'; }else{ switch($option) { case 1: $time_minus = "600"; break; case 2: $time_minus = "3600"; break; case 3: $time_minus = "43200"; break; case 4: $time_minus = "86400"; break; }} } else { $time_minus = "600"; } $time_now = time() - $time_minus; $get_users_query = $db->query("SELECT `id`, `char_name`FROM `users` WHERE `last_online` > $time_now"); $users_online = mysqli_num_rows($get_users_query); ?> <h4>Users Online - <?php echo''.($users_online).''; ?></h4> <div align="center"> <a href="?option=1">Right Now</a> - <a href="?option=2">Past Hour</a> - <a href="?option=3">Past 12 Hours</a> - <a href="?option=4">Past 24 Hours</a> </div> <table class="table"> <tr><th><b>ID</b></th><th><b>Name</b></th></tr> <?php while ($get_users = mysqli_fetch_assoc($get_users_query)) { echo'<tr><td>'.($get_users['id']).'</td><td><a href="profile">'.($get_users['char_name']).'</a></td></tr>'; } ?> </table> You can view a demo at http://panther.x10.mx Email: demo Password: demo Feedback welcome.
-
Oops. Fixed. :)
-
Many thanks for the comments. It's not getting the user id in the first part, instead it's checking to see if a thread is selected so it can be displayed. Also, I thought it was bad practice to use htmlspecialchars(); on inputs? I'm not sanitizing the character name output because when the character was created it would have been checked. I have updated the code. :)
-
1. Fair enough. 2. Don't think so, no errors are being thrown up for me. 3. Which part is insecure? It would be helpful if you could cite specific parts of the code; I'm still learning. :)
-
Which errors? It's all working fine for me (on the demo)? What's wrong with the SQL?
-
Fixed. :) --
-
UPDATED I decided to check out the Panther script and created a quick basic forum. SQL CREATE TABLE IF NOT EXISTS `forum_posts` ( `id` int(11) NOT NULL AUTO_INCREMENT, `tid` int(11) NOT NULL, `char_name` varchar(40) NOT NULL, `content` longtext NOT NULL, `date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ; CREATE TABLE IF NOT EXISTS `forum_threads` ( `id` int(11) NOT NULL AUTO_INCREMENT, `char_name` varchar(40) NOT NULL, `date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `last_post` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', `title` varchar(50) NOT NULL, `content` longtext NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ; Create a "forum" directory within the "mods" directory and add the file main.php <?php include_once('mods/globals.php'); if (array_key_exists('id', $_GET)) { $id = abs(intval($_GET['id'])); $get_thread_query = $db->query("SELECT * FROM `forum_threads` WHERE `id` = $id"); while ($get_thread = mysqli_fetch_assoc($get_thread_query)) { echo '<h4>'.(htmlentities($get_thread['title'])).'</h4> <table class="table"> <tr><td>'.(htmlentities($get_thread['content'])).'</tr></tr> <tr><td>Created on '.($get_thread['date']).' by '.($get_thread['char_name']).'</td></tr> </table>'; } $get_posts_query = $db->query("SELECT `char_name`, `content`, `date` FROM `forum_posts` WHERE `tid` = $id ORDER BY `id` DESC"); while ($get_posts = mysqli_fetch_assoc($get_posts_query)) { echo'<table class="table"> <tr><td>'.(htmlentities($get_posts['content'])).'</tr></tr> <tr><td>Posted on '.($get_posts['date']).' by '.($get_posts['char_name']).'</td></tr> </table>'; } if (array_key_exists('post', $_POST)) { $post = trim($_POST['post']); $date = date("Y-m-d H:i:s"); if(!($post)){ echo '<div class="alert alert-error">You must enter a post!</div>'; }else{ $char_name = $user->getStat('char_name'); $query = $db->prepare("INSERT INTO `forum_posts` (`tid`, `char_name`, `content`, `date`) VALUES (?,?,?,?)"); $query->bind_param("isss", $id, $char_name, $post, $date); $query->execute(); $query = $db->prepare("UPDATE `forum_threads` SET `last_post` = '$date' WHERE `id` = '$id'"); $query->execute(); echo '<div class="alert alert-success">Posted!</div>'; } } ?> <div class="row-fluid marketing" align="center"> <h4>Post to the thread</h4> <form action="" method="POST"> <label>Content</label><textarea name="post"></textarea><br /> <button type="submit" class="btn btn-primary">Post</button> </form> </div> <?php } else { ?> <h4>Forum</h4> <table class="table"> <tr><th><b>Thread Title</b></th> <th><b>Last Post</h2></b></th></tr> <?php $get_threads_query = $db->query("SELECT `id`, `last_post`, `title` FROM `forum_threads` ORDER by `id` DESC"); while ($get_threads = mysqli_fetch_assoc($get_threads_query)) { echo '<tr> <td><a href="?id='.($get_threads['id']).'" >'.(htmlentities($get_threads['title'])).'</a></td> <td>'.($get_threads['last_post']).'</td> </tr>'; } ?> </table> <?php if (array_key_exists('title', $_POST)) { $title = trim($_POST['title']); $content = trim($_POST['content']); $date = date("Y-m-d H:i:s"); if(!($title) || !($content)){ echo '<div class="alert alert-error">You must enter a title and content!</div>'; }else{ $char_name = $user->getStat('char_name'); $query = $db->prepare("INSERT INTO `forum_threads` (`char_name`, `date`, `last_post`, `title`, `content`) VALUES (?,?,?,?,?)"); $query->bind_param("sssss", $char_name, $date, $date, $title, $content); $query->execute(); echo '<div class="alert alert-success">Thread created!</div>'; } } ?> <div class="row-fluid marketing" align="center"> <h4>Create Thread</h4> <form action="" method="POST"> <label>Title</label><input type="text" name="title" /> <br /> <label>Content</label><textarea name="content"></textarea><br /> <button type="submit" class="btn btn-primary">Create Thread</button> </form> </div> <?php } ?> You can see a demo at http://panther.x10.mx Email: demo Password: demo Feedback welcome.