this is staff_classes.php?
ok so i fixed it but when i wanted to create a class i kept getting this Whats the point of having 2 classes with the same name? > Goto Main
<?php
/**
* MCCodes Version 2
* Copyright (C) 2013 KyleMassacere
* All rights reserved.
*
* File: staff_classes.php
* Date: Sat, 12 May 13 07:09:30 +0000
*/
require_once('sglobals.php');
if ($ir['user_level'] != 2)
{
echo 'You cannot access this area.
> <a href="staff.php">Go Back</a>';
die($h->endpage());
}
if (!isset($_GET['action']))
{
$_GET['action'] = '';
}
switch ($_GET['action'])
{
case "addclassform":
addclassform();
break;
case "addclasssub":
addclassSub();
break;
case "editclassform":
editclassform();
break;
case "editclasssub":
editclassSub();
break;
case "selectclass":
selectclass();
break;
default:
echo "Error: This script requires an action.";
break;
}
function addclassSub()
{
global $db, $ir, $c, $h, $userid;
$money = filter_var($_POST["money"],FILTER_VALIDATE_INT);
$crystals = filter_var($_POST["crystals"],FILTER_VALIDATE_INT);
$name = filter_var($_POST["class"],FILTER_SANITIZE_STRING);
$strength = filter_var($_POST["strength"],FILTER_VALIDATE_INT);
$guard = filter_var($_POST["guard"],FILTER_VALIDATE_INT);
$agility = filter_var($_POST["agility"],FILTER_VALIDATE_INT);
$iq = filter_var($_POST["iq"],FILTER_VALIDATE_INT);
$labor = filter_var($_POST["labor"],FILTER_VALIDATE_INT);
if (isset($name))
{
$q = $db->query("SELECT COUNT(*) FROM player_class WHERE classNAME = '{$name}'") or die(mysqli_error());
if ($db->fetch_single($q) > 0)
{
echo 'Whats the point of having 2 classes with the same name?
> <a href="staff.php">Goto Main</a>';
die($h->endpage());
}
else
{
$insert = $db->query("INSERT INTO player_class(classNAME, money, crystals, strength, guard, agility, iq, labor) VALUES('$name', '$money', '$crystals', '$strength', '$guard', '$agility', '$iq', '$labor')");
echo 'Player Class: ' . $name . ' added to the game.> <a href="staff.php">Goto Main</a>';
stafflog_add("{$ir['username']} Created Player Class: $name");
}
}
}
function addclassform()
{
global $db, $ir, $c, $h, $userid;
echo "
<h3>Add Class</h3>
<hr />
<form action='staff_classes.php?action=addclasssub' method='post'>
Name: <input type='text' name='name' placeholder='Name Here' />
Money: <input type='text' name='money' value='0' />
Crystals: <input type='text' name='crystals' value='0' />
Strength: <input type='text' name='strength' value='0' />
Guard: <input type='text' name='guard' value='0' />
Agility: <input type='text' name='agility' value='0' />
IQ: <input type='text' name='iq' value='0' />
Labor: <input type='text' name='labor' value='0' />
<input type='submit' value='Add Class' />
</form>
";
}
function editclassSub()
{
global $db, $ir, $c, $h, $userid;
$id = filter_var($_POST["id"],FILTER_VALIDATE_INT);
$money = filter_var($_POST["money"],FILTER_VALIDATE_INT);
$crystals = filter_var($_POST["crystals"],FILTER_VALIDATE_INT);
$name = filter_var($_POST["class"],FILTER_SANITIZE_STRING);
$strength = filter_var($_POST["strength"],FILTER_VALIDATE_INT);
$guard = filter_var($_POST["guard"],FILTER_VALIDATE_INT);
$agility = filter_var($_POST["agility"],FILTER_VALIDATE_INT);
$iq = filter_var($_POST["iq"],FILTER_VALIDATE_INT);
$labor = filter_var($_POST["labor"],FILTER_VALIDATE_INT);
if (empty($id))
{
echo 'Something went wrong.
> <a href="staff.php">Goto Main</a>';
die($h->endpage());
}
$q = $db->query("SELECT classID FROM `player_class` WHERE `classNAME` = '{$name}' AND `classID` != {$_POST['id']}");
if ($db->num_rows($q) >= 1)
{
echo 'Sorry, you cannot have two classes with the same name.> <a href="staff.php">Goto Main</a>';
die($h->endpage());
}
$db->query("UPDATE `player_class` SET `classNAME` = '$name', `money` = '$money', `crystals` = '$crystals', `strength` = '$strength', `guard` = '$guard', `agility` = '$agility', `iq` = '$iq', `labor` = '$labor' WHERE `classID` = {$_POST['id']}");
echo 'Class ' . $name . ' was edited successfully.
> <a href="staff.php">Goto Main</a>';
stafflog_add("{$ir['username']} Edited Class: $name");
}
function editclassform()
{
global $db, $ir, $c, $h, $userid;
$id = filter_var($_POST["id"],FILTER_VALIDATE_INT);
if (empty($id))
{
echo 'Something went wrong.
> <a href="staff.php">Goto Main</a>';
die($h->endpage());
}
$q = $db->query("SELECT classID, classNAME, money, crystals, strength, guard, agility, iq, labor FROM player_class WHERE classID = {$id}");
if ($db->num_rows($q) == 0)
{
echo 'Class doesn\'t exist.
> <a href="staff.php">Goto Main</a>';
die($h->endpage());
}
$old = $db->fetch_row($q);
echo "
<h3>Editing a Player Class {$id}</h3>
<hr />
<form action='staff_classes.php?action=editclasssub' method='post'>
<input type='hidden' name='id' value='{$id}' />
Name: <input type='text' name='class' value='{$old['classNAME']}' />
Money: <input type='text' name='money' value='{$old['money']}' />
Crystals: <input type='text' name='crystals' value='{$old['crystals']}' />
Strength: <input type='text' name='strength' value='{$old['strength']}' />
Guard: <input type='text' name='guard' value='{$old['guard']}' />
Agility: <input type='text' name='name' value='{$old['agility']}' />
IQ: <input type='text' name='name' value='{$old['iq']}' />
Labor: <input type='text' name='name' value='{$old['labor']}' />
<input type='submit' value='Edit Class' />
</form>
";
}
function selectclass()
{
global $db, $ir, $c, $h, $userid;
echo "
<h3>Editing a Class</h3>
<hr />
<form action='staff_classes.php?action=editclassform' method='post'>
Class: " . class_dropdown(NULL, "id") . "
<input type='submit' value='Edit Class' />
</form>";
}
?>[/Code]