<?php
//require_once('/home/andreblu/public_html/melon/forum/SSI.php');
//Define as needed.
$SQLHost = 'localhost';
$SQLDatabase = '';
$SQLUser = '';
$SQLPassword = '';
$SQLTable = 'whitelist';
$col = "";
$User = $context['user']['name'];
//Connect here
mysql_connect($SQLHost, $SQLUser, $SQLPassword);
mysql_select_db($SQLDatabase);
//Function for current url
function my_url(){
$url = (!empty($_SERVER['HTTPS'])) ? "https://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'] : "http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
return $url;
}
//Check if set and isset($_POST['McUserAdder'])
if(isset($_POST['McUserToAdd']) and isset($_POST['Submit'])){
//Assagin some thing if none
if(empty($_POST['Reason'])){
$Reason = 'Reason';
}else{
$Reason = $_POST['Reason'];
}
//Meh
echo 'Trying to add player : '.$_POST['McUserToAdd'].'<br />';
//Add to here
$AddQuery = "INSERT INTO `".$SQLDatabase."`.`".$SQLTable."` (`name`, `adder`, `reason`) VALUES ('".mysql_real_escape_string($_POST['McUserToAdd'])."', '".mysql_real_escape_string($User)."', '".mysql_real_escape_string($Reason)."');";
//Errors
if(mysql_query($AddQuery)){
echo '<br />User Added<br />';
} else {
print(mysql_error());
echo '<br />';
echo $AddQuery;
echo '<br />';
}
}
echo my_url();
//Form for name and their name. Also reason and such
//Remove will be a 2nd page to reducce mistakes
?>
<form action="<?echo my_url(); ?>" method="POST">
<p>WhiteList: <input type="text" name="McUserToAdd" /></p>
<p>Your Name: <input type="text" name="McUserAdder" /></p>
<p>Reason: <input type="text" name="Reason" /></p>
<input type="hidden" name="Submit" />
<p><input type="submit" value="Submit" /></p>
</form>
<?
//Listing
//Query
$query = "SELECT * FROM `" . $SQLTable . "`;";
$Result = mysql_query($query);
echo "<table width=70% border=1 cellpadding=5 cellspacing=0>";
echo "<tr style=\"font-weight:bold\">
<td>Name</td>
<td>Added By</td>
<td>Reason</td>
</tr>";
$col = "";
while($row = mysql_fetch_assoc($Result)){
if($col == "#00CC33"){
$col = "#00FF33";
}else{
$col = "#00CC33";
}
echo "<tr bgcolor=$col>";
echo "<td>".htmlentities($row['name'])."</td>";
echo "<td>".htmlentities($row['adder'])."</td>";
echo "<td>".htmlentities($row['reason'])."</td>";
echo "</tr>";
}
?>
Thats how i have it set
EDIT: Got it working. Thanks foe helping me with this.