Forgot Password / Register
Site Statistics
Total Members: 520
Total Tutorials: 242
Newsest User: 8884244477
Todays Unique Hits: 352
0 Users 16 Guests Online

Faq system

Okay first were going to make a table in our mysql database called faq_system
Please insert this SQL query into your database...

SQL query:
Code

CREATE TABLE `faq_system` (
`id` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`general` TEXT NOT NULL ,
`staff` TEXT NOT NULL ,
`bugs` TEXT NOT NULL ,
`tos` TEXT NOT NULL ,
`last_by` VARCHAR( 25 ) NOT NULL ,
`last_update` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00'
) ENGINE = MYISAM ;


Okay the table consists of 7 columns. These will be used i the faq system. Please use the following SQL query for this table...
Code

INSERT INTO `faq_system` (
`id` ,
`general` ,
`staff` ,
`bugs` ,
`tos` ,
`last_by` ,
`last_update`
)
VALUES (
NULL , 'None', 'None', 'None', 'None', 'No one', '0000-00-00 00:00:00'
);

That'll basically post our current faq into the database. Dont worry you will get your chance to edit this later.

Now to use the table to make our first page. We will call this page file_faq.php
Feel free to call it whatever you wish. The following is the code we will use in file_faq.php

file_faq.php:
Code

<?
session_start();
//OKAY I HAVNT USED YOUR LOTS USER SYSTEM BEFORE SO IM JUST GOING TO STICK TO WHATS ITS THE CONFIG AND USE HELP FROM THAT. HEHE HOPE YOU CAN UNDERSTAND ME :P
require_once "config.php"; //FOR SECURITY TERMS I WILL USE REQUIRE ONCE INSTEAD OF INCLUDE

//ALSO I WILL SHOW MY OWN WAY OF GETTING INFO FROM THE DATABASE
$userid= $_SESSION['id'];
$userinfo= mysql_query("SELECT * FROM `members` WHERE `id`='$userid'");
//CREATE A QUERY ^^^
$fetch= mysql_fetch_object($userinfo); //GET INFO FROM QUERY
//NOW ITS TIME TO CODE A SIMPLE LAYOUT (JUST A LARGE TABLE) AND SOME CSS
//HOPE THIS DOESNT CONFUSE YOU!

$getfaq_info= mysql_query("SELECT * FROM `faq_system`"); //CREATE QUERY TO GET TABLE INFO
$the= mysql_fetch_object($getfaq_info); //PREPARE TABLE INFO FOR USE IN PAGE
?>
<html>
<head><title>FAQ SYSTEM</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
body,td,th {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
color: #FFFFFF;
}
body {
background-color: #CCCCCC;
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
a:link {
text-decoration: none;
}
a:visited {
text-decoration: none;
}
a:hover {
text-decoration: none;
}
a:active {
text-decoration: none;
}
-->
</style>
</head>
<body>
<div align=center>
<table width="80%" align="center" bgcolor="#333333" border="1" bordercolor="#000000" cellpadding=0 cellspacing=0 frame="box" rules="all">
<tr><td bgcolor=red><div align=center><strong>FAQ SYSTEM</strong></div></td></tr>
<tr><td>
<div align=center>
Welcome <? echo ucfirst($fetch->username); ?>. This page displays the sites faq system. It includes general, staff, bugs and terms of service information.
</div>
</td></tr>
<tR><td bgcolor=red><div align=center><strong>GENERAL
<?
if ($fetch->userlevel >= "4"){ echo "<a href='faq_edit.php'>EDIT FAQ</a>";
//IF USER IS A MODERATOR OR ABOVE LET THEM HAVE A LINK TO THE STAFF EDIT FAQ PAGE
}
?>
</strong></div></td></tr>
<tr><td><br>&nbsp;
<? echo "$the->general"; ?>
<br>&nbsp;
</td></tr>
<tr><td bgcolor=red><div align=center><strong>STAFF
<?
if ($fetch->userlevel == "6"){ echo "<a href='faq_edit.php'>EDIT FAQ</a>"; }
?>
</strong></div></td></tr>
<tr><td><br>&nbsp;
<? echo "$the->staff"; ?>
<br>&nbsp;
</td></tr>
<tr><td bgcolor=red><div align=center><strong>BUGS/EXPLOITS
<?
if ($fetch->userlevel == "6"){ echo "<a href='faq_edit.php'>EDIT FAQ</a>"; }
?>
</strong></div></td></tr>
<tr><td><br>&nbsp;
<? echo "$the->bugs"; ?>
<br>&nbsp;
</td></tr>
<tr><td bgcolor=red><div align=center><strong>TERMS OF SERVICE
<?
if ($fetch->userlevel == "6"){ echo "<a href='faq_edit.php'>EDIT FAQ</a>"; }
?>
</strong></div></td></tr>
<tr><td><br>&nbsp;
<? echo "$the->tos"; ?>
<br>&nbsp;
</td></tr>
<tR><td bgcolor=red><div align=center><strong>LAST UPDATED BY <? echo "".strtoupper($the->last_by).""; ?> ON THE <? echo "$the->last_update"; ?></strong></div></td></tR>
</table><br /><br /><br />

</div>
</body>
</html>

Pretty long huh? Now u now the trouble i go through for you guys xD

And thats not it :o now we need to make an admin/moderator edit page for this faq system. We will be calling this page faq_edit.php
Again feel free to call it anything you like just al long as you change the links in the previous code ^^^ Heres the code for this script.

faq_edit.php:
Code

<?
session_start();
//OKAY I HAVNT USED YOUR LOTS USER SYSTEM BEFORE SO IM JUST GOING TO STICK TO WHATS ITS THE CONFIG AND USE HELP FROM THAT. HEHE HOPE YOU CAN UNDERSTAND ME :P
require_once "config.php"; //FOR SECURITY TERMS I WILL USE REQUIRE ONCE INSTEAD OF INCLUDE

//ALSO I WILL SHOW MY OWN WAY OF GETTING INFO FROM THE DATABASE
$userid= $_SESSION['id'];
$userinfo= mysql_query("SELECT * FROM `members` WHERE `id`='$userid'");
//CREATE A QUERY ^^^
$fetch= mysql_fetch_object($userinfo); //GET INFO FROM QUERY

//OKAY NOW FOR THE LAYOUT, CSS AND ADMIN CHECKS ETC U NO THE DRILL :P

$getfaq_info= mysql_query("SELECT * FROM `faq_system`"); //CREATE QUERY TO GET TABLE INFO
$the= mysql_fetch_object($getfaq_info); //PREPARE TABLE INFO FOR USE IN PAGE
?>
<html>
<head><title>FAQ SYSTEM FOR N00BS :P</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
body,td,th {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
color: #FFFFFF;
}
body {
background-color: #CCCCCC;
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
a:link {
text-decoration: none;
}
a:visited {
text-decoration: none;
}
a:hover {
text-decoration: none;
}
a:active {
text-decoration: none;
}
-->
</style>
</head>
<body>
<div align=center>
<table width="80%" align="center" bgcolor="#333333" border="1" bordercolor="#000000" cellpadding=0 cellspacing=0 frame="box" rules="all">
<tr><td bgcolor=red><div align=center><strong>FAQ SYSTEM - ADMIN CP</strong></div></td></tr>
<tR><td><div align=center>
<? if ($fetch->userlevel < "4"){ ?>
WhAt?!? You can't be here! Only moderators or admins are allowed to see this page!
<? }else{ //HEHE END OF ADMIN/MOD CHECK ?>
Welcome <? echo ucfirst($fetch->username); ?>. Having a nice day, nice cuppa tea? Good. Heres your cpanel...<br>
<font color=red>RETURN TO FAQS?</font><br /><br />
<b>EDIT GENERAL INFO</b><br />
<textarea style="background-color:#FFFFFF; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10px; height:150; width:80%;" name="edit_general"><? echo "$the->general"; ?></textarea><br /><br />
<b>EDIT STAFF INFO</b><br />
<textarea style="background-color:#FFFFFF; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10px; height:150; width:80%;" name="edit_staff"><? echo "$the->staff"; ?></textarea><br /><br />
<b>EDIT BUGS/EXPLOIT INFO</b><br />
<textarea style="background-color:#FFFFFF; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10px; height:150; width:80%;" name="edit_bugs"><? echo "$the->bugs"; ?></textarea><br /><br />
<b>EDIT TERMS OF SERVICE INFO</b><br />
<textarea style="background-color:#FFFFFF; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10px; height:150; width:80%;" name="edit_tos"><? echo "$the->tos"; ?></textarea><br /><br />
<input type=submit style="background-color:#FFFFFF; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10px;" name=edit value="Change" onclick="this.value='Changing...';" /><br /><br />

<?
if (strip_tags($_POST['edit']) && strip_tags($_POST['edit_general']) && strip_tags($_POST['edit_staff']) && strip_tags($_POST['edit_bugs']) && strip_tags($_POST['edit_tos'])){
//IF ALL THE FORMS ABOVE ARE FILLED IN :P
$new_general= $_POST['edit_general'];
$new_staff= $_POST['edit_staff'];
$new_bugs= $_POST['edit_bugs'];
$new_tos= $_POST['edit_tos'];

$date = gmdate('Y-m-d h:i:s'); //DATE AND TIME READY TO INSERT INTO DB
mysql_query("UPDATE `faq_system` SET `general`='$new_general', `staff`='$new_staff', `bugs`='$new_bugs', `tos`='$new_tos', `last_by`='$fetch->username', `last_update`='$date'");
//WHO CARES LET UPDATE ALL OF THEM... EVEN THO THERES ONLY 1 :P

echo "<script>window.location='faq_edit.php';</script>"; //REFRESH THE PAGE
}
?>


<? } ?>
</div></td></tR>
</table><br /><br />
</div>
</body>
</html>


Okay im warning you there could be some errors ;) so please post comments here if their are. I will not SCREAM or BITE u if uve made the mistake yourself. In return u wont do the same :)

Thanks. Now your faq system should be ready to use.
ilyas-shezad
Views:
2473
Rating:
Posted on Saturday 5th January 2008 at 08:12 PM
ShadowMage
ShadowMage
[*code] without the star :P
Posted on Saturday 5th January 2008 at 07:32 PM
DanielXP
DanielXP
Remember bbcodes. [php] or
Code
Posted on Saturday 5th January 2008 at 06:32 PM
kaila
kaila
Jozo, the problem is on the Control panel. The form was never really started.

To make this work, find this code:


<? }else{ //HEHE END OF ADMIN/MOD CHECK ?>
Welcome <? echo ucfirst($fetch->username); ?>. Having a nice day, nice cuppa tea? Good. Heres your cpanel...<br>
<font color=red>RETURN TO FAQS?</font><br /><br />

And after it, add:

<form method="post" name="faqedit">

After the submit button, end the form (</form>)


Good tutorial :)
Posted on Monday 24th December 2007 at 07:33 PM
Jozo
Jozo
When you click change, it just stays on changing for yonks.. :(
Posted on Tuesday 28th August 2007 at 05:40 PM
Dalez
Dalez
Nice - havn't tried yet - can't register on myne yet ;p
Posted on Thursday 16th August 2007 at 07:07 AM
gbt91
gbt91
ehy ily thx
Posted on Wednesday 15th August 2007 at 10:25 PM
ilyas-shezad
ilyas-shezad
nice