<?php
if(isset($_POST["submit"])){
// update level
$LEVEL[old] = $_POST["level"];
$LEVEL[name] = preg_replace("![^0-9]!","",$LEVEL[old]);
if($LEVEL[old] !== $LEVEL[name]){
$ADD[error] = "Level must only contain numbers (0-9)";
}
$LEVEL[description] = $_POST["description"];
if($LEVEL[description] == ""){
$ADD[error] = "Please enter a level description";
}
$LEVEL[lh] = $_POST["lh"];
$LEVEL[tt] = $_POST["tt"];
$LEVEL[faq] = $_POST["faq"];
$LEVEL[departments] = $_POST["departments"];
$LEVEL[operators] = $_POST["operators"];
$LEVEL[lv] = $_POST["levels"];
$LEVEL[stats] = $_POST["stats"];
$LEVEL[transcripts] = $_POST["transcripts"];
$LEVEL[view] = $_POST["view"];
$LEVEL[add] = $_POST["add"];
$LEVEL[edit] = $_POST["edit"];
$LEVEL[delete] = $_POST["delete"];
// Check to see if level exists
$result_search = DATABASE_query("SELECT * FROM $DB[prefix]levels");
while($search = DATABASE_fetch($result_search)){
$SEARCH[level] = $search["level"];
if($SEARCH[level] == $LEVEL[level]){
$ADD[error] = "Level already exists";
}
}
if(!isset($ADD[error])){
DATABASE_query("INSERT INTO $DB[prefix]levels (level,description,lh,tt,faq,departments,operators,levels,stats,transcripts,add,view,edit,delete) VALUES ('$LEVEL[name]','$LEVEL[description]','$LEVEL[lh]','$LEVEL[tt]','$LEVEL[faq]','$LEVEL[departments]','$LEVEL[operators]','$LEVEL[lv]','$LEVEL[stats]','$LEVEL[transcripts]','$LEVEL[add]','$LEVEL[view]','$LEVEL[edit]','$LEVEL[delete]')");
echo("<div align=\"center\">Level added</div>");
}else{
echo("<div align=\"center\">".$ADD[error]."</div>");
}
}else{
//display form..
?>
What is wrong with this code.. there is a form that submits all the info and it returns 'Level Added' but the info is not actually put in the database. DATABASE_query is a function i have for querying the database and it is included into the script and works fine for all my other queries. This has been annoying me for hours!!!
Mike