login script issue
Posted: Sat Aug 30, 2003 7:51 pm
i don't understand why i'm getting an error with this script.. i added a debugging line. the result of that was: the rest is merely creating the page depending on what that part does, so the error is there
the script causing the error keeps stating that the passwords don't match, yet they clearly do. the pws are stored in a md5 maskdebug:
pw: 9cc9e1f6a22e05307d6831087ef5d1e6
db: 9cc9e1f6a22e05307d6831087ef5d1e6
Code: Select all
<?php
include("/home/joshua/includes/fyd.incs.php"); # includes file
# variables used
$pass=MD5($_POST['pass']); $login=FALSE; $duration=NULL; $title='Login Page'; $error=FALSE; $gmto=NULL;
$uid=NULL;
if(isset($_POST['un'])){ # check the db if this isn't the first loading of the page
$un=$_POST['un']; # what was the passed username?
$db=mysql_connect($host, $login2, $pass2) or die("cannot access mysql"); # connect
$fyd=mysql_select_db('findyourdesire', $db) or die("cannot connect to db"); # select the db
$lookup=mysql_query("SELECT * FROM users WHERE username='$un'", $db);
if(mysql_num_rows($lookup)==0){ $error=TRUE; } # there was no user by that name
else{ # retrieve the info
$info=mysql_fetch_array($lookup); # get all the info associated with the user
if($pass==$info['password']){ # the passwords match
$sa=$info['site_access'];
if((contains($sa, $regulars))||(contains($sa, $desireds))){ # you're not suspended
$login=TRUE; $duration=$info['login_duration']; # set login to true, cookie duration code
$gmto=$info['gmt_offset']; $rtds=$info['tds']; $utds=$tds[$rtds]; # set the gmt offset & time display
$currip=$_SERVER['REMOTE_ADDR']; # get the new ip
$update=mysql_query("UPDATE users SET last_login_ip='$currip',last_login_date='$now' WHERE uid='$uid'", $db); # update login date and ip
$expire=time()+(60*$durr[$duration]); # set expiration by formula time()+seconds*minutes*hrs*days*yrs
setcookie(un, $un, $expire); # set username
setcookie(pw, $pass, $expire); # set password
setcookie(login, TRUE, $expire); # set login
setcookie(gmto, $gmto, $expire); # set the gmt offset
setcookie(utds, $rtds, $expire); # set the time display style
}
}
}
}