Skip to main content
Inspiring
November 9, 2006
Answered

Login trouble

  • November 9, 2006
  • 2 replies
  • 348 views
Hi,

I am using Dreamweaver 8 on a Mac and PHP and MySQL
I'am trying to figure out the "login user" behaviour.
When I test the my login page it doesnot work.

The browser returns:
Unknown column 'nieuw' in 'where clause'

"nieuw" is the name I use for testing it is not column in my database.

Any help will be appreciated.

Jos

The PHP code of the page is below:
By mistake I named de database connection rs instead of db.



?php require_once('Connections/rsNormaal.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$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;
}
}
?>
<?php
// *** Validate request to login to this site.
if (!isset($_SESSION)) {
session_start();
}

$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
$_SESSION['PrevUrl'] = $_GET['accesscheck'];
}

if (isset($_POST['user'])) {
$loginUsername=$_POST['user'];
$password=$_POST['password'];
$MM_fldUserAuthorization = "";
$MM_redirectLoginSuccess = "r813_loginOK.php";
$MM_redirectLoginFailed = "r812_loginfailed.php";
$MM_redirecttoReferrer = false;
mysql_select_db($database_rsNormaal, $rsNormaal);

$LoginRS__query=sprintf("SELECT `user`, password FROM passwords WHERE `user`=%s AND password=%s",
GetSQLValueString($loginUsername, "-1"), GetSQLValueString($password, "text"));

$LoginRS = mysql_query($LoginRS__query, $rsNormaal) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
if ($loginFoundUser) {
$loginStrGroup = "";

//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 );
}
}
?>



<form ACTION="<?php echo $loginFormAction; ?>" method="POST" name="form1">
<table width="350" border="0" class="rimon_tekst">
<tr>
<td width="110" height="25"><b>Gebruikersnaam</b></td>
<td width="140" height="25"><input name="user" type="text" id="user" size="20" maxlength="20"></td>
</tr>
<tr>
<td width="110" height="25"><b>Wachtwoord</b></td>
<td width="140" height="25"><input name="password" type="text" id="password" size="20" maxlength="20"></td>
</tr>
<tr>
<td width="110" height="25"> </td>
<td width="140" height="25"><input type="submit" name="Submit" value="Login"></td>
</tr>
</table>
</form>

This topic has been closed for replies.
Correct answer arnhemcs-QVZdUa
Thanks Again. It works properly now. I am much obliged.

Jos

2 replies

arnhemcs-QVZdUaAuthorCorrect answer
Inspiring
November 9, 2006
Thanks Again. It works properly now. I am much obliged.

Jos
Inspiring
November 9, 2006
arnhemcs wrote:
> GetSQLValueString($loginUsername, "-1"), GetSQLValueString($password,
> "text"));

This section should be like this:

GetSQLValueString($loginUsername, "text"), GetSQLValueString($password,
"text"));

--
David Powers
Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
http://foundationphp.com/