I am not asking anyone to code for me, I am asking for the first step of how to go about doing the back end. Anyone in this forum who asks questions about code could be said the same thing "you are asking about code, go pay someone". I am hoping someone can
point me in the right direction to design a backend
myself.
--------------- Added [DATE]1403673493[/DATE] at [TIME]1403673493[/TIME] ---------------
So far, I've gotten this far:
PHP Code:
<?php
// Rosters
// by DrMath
// ######################## SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);
// #################### PRE-CACHE TEMPLATES AND DATA ######################
$phrasegroups = array('style');
$specialtemplates = array('products');
// ########################## REQUIRE BACK-END ############################
require_once('./global.php');
require_once(DIR . '/includes/adminfunctions_template.php');
$this_script = 'rosters';
$rpm_ver = 1.0;
$rpm_mouseover_fontcolor = '#D04850';
// ######################## CHECK ADMIN PERMISSIONS #######################
if (!can_administer('canadminforums'))
{
print_cp_no_permission();
}
print_cp_header();
// Get Profile Fields //
$sql = "SELECT profilefieldid FROM " . TABLE_PREFIX . "profilefield";
$result = $db->query_read($sql);
$fields = array();
while( $a = mysql_fetch_array($result) ) {
$fields[] = "field" . $a[0];
}
// Get Main Games //
$sql = "SELECT profilefieldid, data FROM " . TABLE_PREFIX . "profilefield WHERE profilefieldid = 5";
$result = $db->query_read($sql);
$gamesbase = mysql_fetch_array($result);
$gamesbase = unserialize($gamesbase[1]);
foreach ($gamesbase as $game) {
$games[] = $game;
}
// Game Status //
$gamestatuses = array('Divisions', 'Guilds', 'Divisions in Development', 'Miscellaneous');
/////////////////////// front page
if ( empty($_REQUEST['do']) ) {
print_form_header($this_script, 'add');
print_table_header('Add Game');
print_select_row('Main Game', 'game', $games );
print_input_row('Abbreviation', 'abbrev');
print_input_row('Account Name', 'acctname');
print_select_row('Account Profile Field', 'proffield', $fields);
print_select_row('Game Status', 'status', $gamestatuses);
print_submit_row('Submit New Game');
}
////////////////////// get current games
$sql = "SELECT * FROM " . TABLE_PREFIX . "gamelist";
$result = $db->query_read($sql);
print_form_header($this_script, 'remove');
print_table_header('Current Games in Roster',6);
echo "<tr><th>Game</th><th>Abbreviation</th><th>In-Game Name</th><th>Profile Field</th><th>Status</th><th>Delete?</th></tr>";
while ($game = mysql_fetch_array($result)) {
echo "<tr>
<td>$game[1]</td>
<td>$game[2]</td>
<td>$game[3]</td>
<td>$game[4]</td>
<td>$game[5]</td>
<td stlye='text-align:center;'><input type='checkbox' name='delete' value='$game[0]'></td>
</tr>";
}
print_table_footer(6,'','',0);
/////////////////////// add
if ( $_REQUEST['do'] == 'add' ) {
if ( empty($_REQUEST['game']) OR empty($_REQUEST['abbrev']) OR empty($_REQUEST['acctname']) OR empty($_REQUEST['proffield']) OR empty($_REQUEST['status'])) { rpm_print_stop_back('Please be sure every field is filled out before submitting.'); }
$game = $_REQUEST['game'];
$abbrev = $_REQUEST['abbrev'];
$acctname = $_REQUEST['acctname'];
$proffield = $_REQUEST['proffield'];
$status = $_REQUEST['status'];
$sql = "INSERT INTO TABLE " . TABLE_PREFIX . "gamelist (gamename, abbreviation, ingamename, profilefield, status)
VALUES ($game, $abbrev, $acctname, $proffield, $status)";
$db->query_write($sql);
if ($db->affected_rows() != 0) {echo "Game Added!";} else { $db->error();}
}
print_cp_footer();
?>
So now that these are populated how I'd like I can created an "add" post and run the query to add it to a new table yea? Now can anyone tell me how to add it to the menu on the left side and create an administrator "canadmin" property?
Also, for some reason my "add" code is not working properly. I think the DB writing isn't happening.