bradgrafelman;10999133 wrote:This part of your new if() statement:
($_POST['removeuser'] != "")
will never be true because you don't have any form entities named 'removeuser' that are getting POST'ed.
Ok....
changed to this
if ((isset($_POST['user'])) && ($_POST['user'] != "")) {
$deleteSQL = sprintf("DELETE FROM members WHERE user_id=%s,",
GetSQLValueString($_POST['user'], "text"));
and now i get :
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
I don't understand how line on is requiring once the MySQL connection file.....
I am sorry, I just understand what you are saying. I get that it is failing due to removeuser was not in fields being posted, however 'user' is. So I changed it to the only field that i have not removed that is being POSTED and still doesn't work....
Full Code:
<?php require_once('connect.php');?> <----line 1
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
if ((isset($_POST['user'])) && ($_POST['user'] != "")) {
$deleteSQL = sprintf("DELETE FROM members WHERE user_id=%s,",
GetSQLValueString($_POST['user'], "text"));
$Result1 = mysql_query($deleteSQL) or die(mysql_error());
$deleteGoTo = "remove-user-ok.php";
if (isset($_SERVER['QUERY_STRING'])) {
$deleteGoTo .= (strpos($deleteGoTo, '?')) ? "&" : "?";
$deleteGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $deleteGoTo));
}
?>
<style type="text/css">
body,td,th {
color: #000;
}
</style>
<table width="212" border="0">
<th width="206" align="center" scope="col">
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST" >
<h5 align="center"><em>Remove System User</em></h5>
<p align="center"> </p>
<h6>Username:
<input type="text" name="user" id="user" />
</h6>
<h6> </h6>
<h6> </h6>
<h6>
<input type="image" name="submit" onclick="submit" img="img" src="../images/submitactive.gif" alt="button" width="75" height="21" />
</h6>
<p> </p>
</form>
</table>