hi..
i'll ask some question regarding my system login part..
This is my databasae connection..
<?
include("constants.php");
class MySQLDB
{
var $connection; //The MySQL database connection
function MySQLDB(){
/* Make connection to database */
$this->connection = mysql_connect(DB_SERVER, DB_USER, DB_PASS) or die(mysql_error());
mysql_select_db(DB_NAME, $this->connection) or die(mysql_error());
function confirmUserPass($username, $password){
/* Add slashes if necessary (for query) */
if(!get_magic_quotes_gpc()) {
$username = addslashes($username);
}
/* Verify that user is in database */
$q = "SELECT password FROM ".userpass." WHERE username = '$username'";
$result = mysql_query($q, $this->connection);
if(!$result || (mysql_numrows($result) < 1)){
return 1; //Indicates username failure
}
/* Validate that password is correct */
if($password == $dbarray['password']){
return 0; //Success! Username and password confirmed
}
else{
return 2; //Indicates password failure
}
}
$q = "SELECT id FROM ".userpass." WHERE username = '$username'";
$result = mysql_query($q, $this->connection);
if(!$result || (mysql_numrows($result) < 1)){
return 1; //Indicates username failure
}
?>
my system does not run well.the username as well as the password is saved on it's database.my database name is 'records' and it's table name is 'userpass'...i can't log..what do you think the problem with my code?
all i want is insert username and password from the textbox in the login menu then validate from it's database. when i click the login button,it will proceed to my main page.