Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with password validation

Status
Not open for further replies.

benzito

ISP
Jan 8, 2002
144
US
I'm getting an error whenever I try to pass a password from a form. I ran the password field queries below and get the following output. My varchar length for the password column is set for 255. With the first query, I'm returned the password unencrypted, with the second it's returned encrypted...I've tried entering the password both plain text and encrypted in my form and still no joy. Any suggestions? Thanks from the obvious newbie!



SELECT password FROM login
where loginName = 'tfreeman' =password bux


SELECT password( 'tfreeman' ) =password('tfreeman')
0efd8d9c2edcd25c

Error = "The Login Name, 'tfreeman' exists, Please try password again."

--------------------------------------------------


<?php
/* Program: Login.php
Desc: Login progam to provide access to the TT app. for existing users.
*/
session_start();
session_register('auth');
session_register('logname');
include(&quot;connect.inc&quot;);
switch (@$do)
{
case &quot;login&quot;:
$connection = mysql_connect($host, $user,$password)
or die (&quot;Couldn't connect to server.&quot;);
$db = mysql_select_db($database, $connection)
or die (&quot;Couldn't select database.&quot;);
$sql = &quot;SELECT loginName FROM login
WHERE loginName = '$fusername'&quot;;
$result = mysql_query($sql) or die (&quot;Couldn't execute query.&quot;);
$num = mysql_num_rows($result);
if ($num == 1) // login name was found
{
$sql = &quot;SELECT loginName FROM login
WHERE loginName = '$fusername'
AND password=password('$fpassword')&quot;;
$result2 = mysql_query($sql)
or die(&quot;Couldn't execute query.&quot;);
$num2 = mysql_num_rows($result2);
if ($num2 > 0) // password is correct
{
$auth=&quot;yes&quot;;
$logname=$fusername;
$today = date(&quot;y-m-d h:m:s&quot;);
$sql = &quot;INSERT INTO user_logins (loginName,loginTime)
VALUES ('$logname','$today')&quot;;
mysql_query($sql) or die (&quot;Can't execute query.&quot;);
header(&quot;Location: tt.php&quot;);
}
else // password is not correct
{
unset($do);
$message=&quot;Please try password again.<br>&quot;;
include(&quot;login_form.inc&quot;);
}
}
elseif ($num == 0) // login name not found
{
unset ($do);
$message = &quot;The Login Name, '$fusername' exists, Please try password again<br>&quot;;
include (&quot;login_form.inc&quot;);
}
break;

default;
include (&quot;login_form.inc&quot;);
}
?>
 
Figured it out ...stupid mistake >>> incorrect function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top