Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-03-2006, 09:51 AM   PM User | #1
urgido
Regular Coder

 
Join Date: Aug 2005
Posts: 257
Thanks: 8
Thanked 0 Times in 0 Posts
urgido is an unknown quantity at this point
error with login auth

I have the next code:

PHP Code:
$link mysql_connect('localhost''myusername''mypass' );
mysql_select_db('mydb') or die("check your info."); 

$_POST['username'] = $username;
$_POST['password'] = $password;
$password md5($password);

$consult"SELECT * FROM users WHERE password='$password' AND username='$username'";

$resultmysql_query($consult,$link);
echo 
mysql_error();


// Check auth
if($username=$row['username'] && $password=$row['password']){
 echo 
"all success";
}else{
 echo 
"login failed";

For some reasons my code don't work! Can somebody fix this? my password are encrypted(md5). Regards
urgido is offline   Reply With Quote
Old 11-03-2006, 11:35 AM   PM User | #2
ess
Regular Coder

 
Join Date: Oct 2006
Location: United Kingdom
Posts: 865
Thanks: 7
Thanked 29 Times in 28 Posts
ess will become famous soon enough
First of all...please correct the following statements

from
PHP Code:
$_POST['username'] = $username;
$_POST['password'] = $password
to
PHP Code:
$username $_POST['username']; 
$password $_POST['password'] ; 
Second...if you haven't stored user's passwords in the database encrypted in md5...it won't work.

So...I would advise to you get the script working without using md5 first...

once you have...go back and implement md5 in your script.

Good luck

ess is offline   Reply With Quote
Old 11-03-2006, 08:08 PM   PM User | #3
urgido
Regular Coder

 
Join Date: Aug 2005
Posts: 257
Thanks: 8
Thanked 0 Times in 0 Posts
urgido is an unknown quantity at this point
implementation for md5 is made. check the footer of my message

I made the changes that you say me and the problem is same.

Regards

Last edited by urgido; 11-03-2006 at 08:12 PM..
urgido is offline   Reply With Quote
Old 11-03-2006, 10:32 PM   PM User | #4
dumpfi
Regular Coder

 
Join Date: Jun 2004
Posts: 565
Thanks: 0
Thanked 18 Times in 18 Posts
dumpfi will become famous soon enough
Use mysql_fetch_assoc.

dumpfi
__________________
"Failure is not an option. It comes bundled with the software."
....../)/)..(\__/).(\(\................../)_/)......
.....(-.-).(='.'=).(-.-)................(o.O)...../<)
....(.).(.)("}_("}(.)(.)...............(.)_(.))¯/.
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Little did the bunnies suspect that one of them was a psychotic mass murderer with a 6 ft. axe.
dumpfi is offline   Reply With Quote
Old 11-03-2006, 10:49 PM   PM User | #5
urgido
Regular Coder

 
Join Date: Aug 2005
Posts: 257
Thanks: 8
Thanked 0 Times in 0 Posts
urgido is an unknown quantity at this point
I put the following code:

PHP Code:
while ($fila mysql_fetch_assoc($result)) {
   
//nothing

How I can compare the values to know if there are correct. I you remember that the username and password must coincide to be able to go to cp.php of another way errorcp.php
?

Regards
urgido is offline   Reply With Quote
Old 11-04-2006, 04:01 AM   PM User | #6
Brandoe85
teh Moderatorinator


 
Join Date: Sep 2004
Location: USA
Posts: 2,472
Thanks: 4
Thanked 40 Times in 40 Posts
Brandoe85 will become famous soon enough
You could use mysql_num_rows():
PHP Code:
$link mysql_connect('localhost''myusername''mypass' );
mysql_select_db('mydb') or die("check your info."); 

$_POST['username'] = $username;
$_POST['password'] = $password;
$password md5($password);

$consult"SELECT * FROM users WHERE password='$password' AND username='$username'";

$resultmysql_query($consult,$link);

if(
mysql_num_rows($result) > 0)
{
    
// good login...do whatever
}
else
{
    
// login failed.

Ref:
http://us2.php.net/mysql_num_rows
__________________
-Brando
Why using tables for eating is stupid!
Brandoe85 is offline   Reply With Quote
Old 11-04-2006, 04:06 AM   PM User | #7
urgido
Regular Coder

 
Join Date: Aug 2005
Posts: 257
Thanks: 8
Thanked 0 Times in 0 Posts
urgido is an unknown quantity at this point
Brandoe85 THANKKKKKKKKKKKKKKKKKKKKKKKKKK YOU.

BEST REGARDS!
urgido is offline   Reply With Quote
Old 11-04-2006, 04:11 AM   PM User | #8
Brandoe85
teh Moderatorinator


 
Join Date: Sep 2004
Location: USA
Posts: 2,472
Thanks: 4
Thanked 40 Times in 40 Posts
Brandoe85 will become famous soon enough
Woops, I didn't put in the other fixes for the tranposed variable names but you get the idea. Good luck
__________________
-Brando
Why using tables for eating is stupid!
Brandoe85 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:24 AM.


Advertisement
Log in to turn off these ads.