SBDTHRU
02-25-2010, 06:19 PM
I am trying to setup a report system. Code won't deposit to the database for some reason.. Heres the code.
<?php
ob_start(); //Allow cookies
include("config.php"); //get config file
switch($_GET[act]){ //change links to ?act=
default: //Make this our default page.
if($logged[username] && !$_POST[report]){ //check if they are logged in
echo "<font type='verdana' size='2'><body link='black' alink='black' vlink='black'>
<form method=\"post\" action=\"index.php?x=Report&act=Do\">
<b>Username</b>:<br />
<input type=\"text\" name=\"user\" size=\"15\"><br />
<b>Current Bankroll</b>:<br />
<input type=\"text\" name=\"report\" size=\"15\"><br />
<b>Starting Bankroll</b>:<br />
<input type=\"text\" name=\"prev\" size=\"15\"><br />
<input type=\"submit\" name=\"report\" value=\"Report User\">
</form>
"; //Echo the form
}elseif(!$logged[username] && !$_POST[report]){ //If Not Logged in
echo "<b>Error</b>: You Are Not Logged In"; //Echo Error
} //End Else If
break; //End the page
case 'Do': //Make the Go case.
if($logged[username] && $_POST[report]){ //Check if they are logged in and the form is submitted
$user = stripslashes(htmlspecialchars($_POST[user])); //User Variable
$reason = stripslashes(addslashes(htmlspecialchars($_POST[reason]))); //Reason Variable
$prev = stripslashes(addslashes(htmlspecialchars($_POST[reason])));
$date = date("l, F d, Y");
$errs = array(); //Make An Array
if(empty($user)){
$errs[] = "<b>Error</b>: You Must Enter A Username<br />"; //echo error
}//end
if(empty($reason)){ //if reason is empty
$errs[] = "<b>Error</b>: You Must Enter Bankroll Info<br />"; //echo error
} //End
if(count($errs) > 1){ //If there are more than 1 errors
foreach($errs as $oops){ //Count them up
echo "$oops"; //Echo Errors
}
}else{
$report = mysql_query("INSERT INTO reps(`username`,`reason`,`prev`,`date`,`reported_by`) VALUES ('$user','$reason','$prev','$date','$logged[username]')") or die(mysql_error()); //do the query or die with an error
echo "$user Has Been Reported."; //Echo Error
} //End the queryness
}elseif($logged[username] && !$_POST[report]){ //If logged in but form not submitted
echo "<b>Error</b>: You Must Go Back And Submit The Form"; //Echo error
}elseif(!$logged[username] && !$_POST[report]){ //If not loged in and no form
echo "<b>Error</b>: You Are Not Logged In"; //Echo Error
}//End check login
break; //End The Page
} //End switch get
?>
<?php
ob_start(); //Allow cookies
include("config.php"); //get config file
switch($_GET[act]){ //change links to ?act=
default: //Make this our default page.
if($logged[username] && !$_POST[report]){ //check if they are logged in
echo "<font type='verdana' size='2'><body link='black' alink='black' vlink='black'>
<form method=\"post\" action=\"index.php?x=Report&act=Do\">
<b>Username</b>:<br />
<input type=\"text\" name=\"user\" size=\"15\"><br />
<b>Current Bankroll</b>:<br />
<input type=\"text\" name=\"report\" size=\"15\"><br />
<b>Starting Bankroll</b>:<br />
<input type=\"text\" name=\"prev\" size=\"15\"><br />
<input type=\"submit\" name=\"report\" value=\"Report User\">
</form>
"; //Echo the form
}elseif(!$logged[username] && !$_POST[report]){ //If Not Logged in
echo "<b>Error</b>: You Are Not Logged In"; //Echo Error
} //End Else If
break; //End the page
case 'Do': //Make the Go case.
if($logged[username] && $_POST[report]){ //Check if they are logged in and the form is submitted
$user = stripslashes(htmlspecialchars($_POST[user])); //User Variable
$reason = stripslashes(addslashes(htmlspecialchars($_POST[reason]))); //Reason Variable
$prev = stripslashes(addslashes(htmlspecialchars($_POST[reason])));
$date = date("l, F d, Y");
$errs = array(); //Make An Array
if(empty($user)){
$errs[] = "<b>Error</b>: You Must Enter A Username<br />"; //echo error
}//end
if(empty($reason)){ //if reason is empty
$errs[] = "<b>Error</b>: You Must Enter Bankroll Info<br />"; //echo error
} //End
if(count($errs) > 1){ //If there are more than 1 errors
foreach($errs as $oops){ //Count them up
echo "$oops"; //Echo Errors
}
}else{
$report = mysql_query("INSERT INTO reps(`username`,`reason`,`prev`,`date`,`reported_by`) VALUES ('$user','$reason','$prev','$date','$logged[username]')") or die(mysql_error()); //do the query or die with an error
echo "$user Has Been Reported."; //Echo Error
} //End the queryness
}elseif($logged[username] && !$_POST[report]){ //If logged in but form not submitted
echo "<b>Error</b>: You Must Go Back And Submit The Form"; //Echo error
}elseif(!$logged[username] && !$_POST[report]){ //If not loged in and no form
echo "<b>Error</b>: You Are Not Logged In"; //Echo Error
}//End check login
break; //End The Page
} //End switch get
?>