I tried to Incorporate a log-in feature to my website to make some content more secure but I am running into problems again. I created a new table in my database for Users, Passwords, and access or power level. Whenever i try to log into the page i get this error Unknown column 'Power' in 'field list'. I'm not sure why I am getting this error, any help is greatly appreciated.
Log-in page
PHP Code:
<?php require_once('Connections/Jobs.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$LoginRS__query=sprintf("SELECT `User`, Password, Power Level FROM users WHERE `User`=%s AND Password=%s",
GetSQLValueString($loginUsername, "-1"), GetSQLValueString($password, "text"));
$LoginRS = mysql_query($LoginRS__query, $Jobs) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
if ($loginFoundUser) {
//declare two session variables and assign them
$_SESSION['MM_Username'] = $loginUsername;
$_SESSION['MM_UserGroup'] = $loginStrGroup;
if (isset($_SESSION['PrevUrl']) && false) {
$MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
}
header("Location: " . $MM_redirectLoginSuccess );
}
else {
header("Location: ". $MM_redirectLoginFailed );
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>403 Access Denied</title>
<style type="text/css">
<!--
body {
font: 100% Verdana, Arial, Helvetica, sans-serif;
background: #666666;
margin: 0; /* it's good practice to zero the margin and padding of the body element to account for differing browser defaults */
padding: 0;
text-align: center; /* this centers the container in IE 5* browsers. The text is then set to the left aligned default in the #container selector */
color: #000000;
}
.oneColElsCtr #container {
width: 46em;
background: #FFFFFF;
margin: 0 auto; /* the auto margins (in conjunction with a width) center the page */
border: 1px solid #000000;
text-align: left; /* this overrides the text-align: center on the body element. */
}
.oneColElsCtr #mainContent {
padding: 0 20px; /* remember that padding is the space inside the div box and margin is the space outside the div box */
}
.oneColElsCtr #container #mainContent h1 {
font-size: 30px;
}
-->
</style></head>
<body class="oneColElsCtr">
<div id="container">
<div id="mainContent">
<h1 align="center">Error 403: Access Denied</h1>
<h1 align="center">You must be logged in to view this page</h1>
<form ACTION="<?php echo $loginFormAction; ?>" id="form1" name="form1" method="POST">
<div align="center"><table width="100%" border="0">
<tr>
<th scope="col"><table width="500" border="0">
<tr>
<th width="250" scope="col"><div align="right">Username</div></th>
<th width="250" scope="col"><div align="left">
<input type="text" name="User" id="User" />
</div></th>
</tr>
<tr>
<td width="250"><div align="right"><strong>Password</strong></div></td>
<td width="250"><label>
<div align="left">
<input type="password" name="Password" id="Password" />
</div>
</label></td>
</tr>
</table></th>
</tr>
<tr>
<td><div align="center">
<label>
<input type="submit" name="GO" id="GO" value="Login" />
</label>
</div></td>
</tr>
</table>
</div>
</form>
<p align="center">If you are an employer looking to post a job please send an email to <a href=""></a> and request a username and password</p>
<p align="center">Please login or return to the <a href="Index.php">Main Page</a> </p>
</div>
</div>
</body>
</html>
I tried to Incorporate a log-in feature to my website to make some content more secure but I am running into problems again. I created a new table in my database for Users, Passwords, and access or power level. Whenever i try to log into the page i get this error Unknown column 'Power' in 'field list'. I'm not sure why I am getting this error, any help is greatly appreciated.
Log-in page
PHP Code:
<?php require_once('Connections/Jobs.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$LoginRS__query=sprintf("SELECT `User`, Password, Power Level FROM users WHERE `User`=%s AND Password=%s",
GetSQLValueString($loginUsername, "-1"), GetSQLValueString($password, "text"));
$LoginRS = mysql_query($LoginRS__query, $Jobs) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
if ($loginFoundUser) {
//declare two session variables and assign them
$_SESSION['MM_Username'] = $loginUsername;
$_SESSION['MM_UserGroup'] = $loginStrGroup;
if (isset($_SESSION['PrevUrl']) && false) {
$MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
}
header("Location: " . $MM_redirectLoginSuccess );
}
else {
header("Location: ". $MM_redirectLoginFailed );
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>403 Access Denied</title>
<style type="text/css">
<!--
body {
font: 100% Verdana, Arial, Helvetica, sans-serif;
background: #666666;
margin: 0; /* it's good practice to zero the margin and padding of the body element to account for differing browser defaults */
padding: 0;
text-align: center; /* this centers the container in IE 5* browsers. The text is then set to the left aligned default in the #container selector */
color: #000000;
}
.oneColElsCtr #container {
width: 46em;
background: #FFFFFF;
margin: 0 auto; /* the auto margins (in conjunction with a width) center the page */
border: 1px solid #000000;
text-align: left; /* this overrides the text-align: center on the body element. */
}
.oneColElsCtr #mainContent {
padding: 0 20px; /* remember that padding is the space inside the div box and margin is the space outside the div box */
}
.oneColElsCtr #container #mainContent h1 {
font-size: 30px;
}
-->
</style></head>
<body class="oneColElsCtr">
<div id="container">
<div id="mainContent">
<h1 align="center">Error 403: Access Denied</h1>
<h1 align="center">You must be logged in to view this page</h1>
<form ACTION="<?php echo $loginFormAction; ?>" id="form1" name="form1" method="POST">
<div align="center"><table width="100%" border="0">
<tr>
<th scope="col"><table width="500" border="0">
<tr>
<th width="250" scope="col"><div align="right">Username</div></th>
<th width="250" scope="col"><div align="left">
<input type="text" name="User" id="User" />
</div></th>
</tr>
<tr>
<td width="250"><div align="right"><strong>Password</strong></div></td>
<td width="250"><label>
<div align="left">
<input type="password" name="Password" id="Password" />
</div>
</label></td>
</tr>
</table></th>
</tr>
<tr>
<td><div align="center">
<label>
<input type="submit" name="GO" id="GO" value="Login" />
</label>
</div></td>
</tr>
</table>
</div>
</form>
<p align="center">If you are an employer looking to post a job please send an email to <a href=""></a> and request a username and password</p>
<p align="center">Please login or return to the <a href="Index.php">Main Page</a> </p>
</div>
</div>
</body>
</html>
When an mysql error says unknown column '....' in field list, that means that that field does not exist in that table..
maybe check the spelling/capitalization/ missing commas (if the field is Power and the next one is Level then you need to add a comma), but in this case it looks like it is looking for the word Power, when it should actually be looking for `Power Level`... if your column name is Power Level with a space. then you should surround it in ticks (`), if that doesnt work, then change the name of the column from Power Level to Power_Level and change it in the code too, but that should fix it.