General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old August 25th, 2003, 10:02 PM
EvilXParser EvilXParser is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 9 EvilXParser User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
once again im stumped

I have searched online and tried myself to solve this, but i cant, again im stuck!

I have the following code:

$result=mysql_query("SELECT * FROM sb_members WHERE pass = '$password' AND user = '$username'");

if(is_object($result)){
echo('Ur IN'); }else{
echo $password;}

For some reason it does not work right. I made a test acount and i can login. I believe it may be my SQL syntax, mayby something is wrong on there? or perhaps its the is_object? Can anyone show me how this can be done or give me an example or something that works???


I have also tried using user, pass instead of *. I store the Login username and pass in 2 rows called User and Pass.

Reply With Quote
  #2  
Old August 25th, 2003, 10:18 PM
EvilXParser EvilXParser is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 9 EvilXParser User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
to add on to this issue this is more code:


$user=$_POST['user'];
$password=$_POST['ps'];
if(empty($user) || (empty($password))){
echo('Invalid Password of Username, Please Check your Username and Password.');
}else{


//Check login Against Databse, If succesful create a cookie and redirect to admin page

include("../../include/db.php");

$password=md5($password);
$result=mysql_query("SELECT user, pass FROM sb_members WHERE pass = '$password' AND user = '$user'");
if(is_object($result)){


echo('Ur IN');
}else{
echo $password;
echo $user;
}




For some reason even when i get an invalid login, it will echo me the md5 password but not the username, its as if the username disappears!

Reply With Quote
  #3  
Old August 25th, 2003, 10:46 PM
EvilXParser EvilXParser is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 9 EvilXParser User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Okie, please ignore the top, there is something wrong with the way im vlaidating it. Is there an alternative to:

if(is_object($result)){


echo('Ur IN');
}else{
}


????

Right now i have:


$usern=$_POST['user'];
$password=$_POST['ps'];
if(empty($usern) || (empty($password))){
echo('Invalid Password of Username, Please Check your Username and Password.');
}else{


//Check login Against Databse, If succesful create a cookie and redirect to admin page

include("../../include/db.php");

$password=md5($password);
$result=mysql_query("SELECT user,pass FROM `sb_members` WHERE pass = '$password' AND user = '$usern'");
if(is_object($result)){


echo('Ur IN');
}else{
}




}


Can somone help?

Reply With Quote
  #4  
Old August 26th, 2003, 07:59 AM
dhouston's Avatar
dhouston dhouston is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Tennessee
Posts: 1,355 dhouston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to dhouston
Try just if($result).

Reply With Quote
  #5  
Old August 29th, 2003, 11:53 AM
EvilXParser EvilXParser is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 9 EvilXParser User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
that validates it no matter what i type in and submit, i need to cmpare it against the info the user signed up with.

Reply With Quote
  #6  
Old August 29th, 2003, 01:09 PM
dhouston's Avatar
dhouston dhouston is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Tennessee
Posts: 1,355 dhouston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to dhouston
Gotcha. I thought you were just testing to see if you got a valid return. You'll need to use mysql_fetch_array() or one of the related functions in order to actually retrieve your results and validate data. Your logic flow should be basically: If there's a result (or no error), retrieve the rows and compare them to your submitted values; else print an error. You'll probably still want to eschew the is_object() call. I recommend jumping over to php.net, searching for the mysql_query() function, and browsing the functions that'll appear on the left-hand side of your screen to familiarize yourself with what's available to you. I often find useful things I hadn't known about by doing just this sort of treasure hunt.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > once again im stumped


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT