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 4th, 2003, 04:15 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
Help!!!

Can someone tell whats wrong with the following piece of code?


Code:

<?php
if(isset($_POST['username']) && (isset($_POST['password']))){
//start validating username and password rom Database

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

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

$result=mysql_query("SELECT * FROM users WHERE userName=$username AND userPass=$password");


//logs in user or gives em an error
if(is_object($result)){
session_start();
session_register('username');

echo("You are now logged in.");


t_redirect("?nav=home","900");}

else{ echo "ERROR: Wrong Username or Password, Please try again, or register, if you haven't.";}

}
else echo('


<TABLE WIDTH=532 BORDER=0 CELLPADDING=0 CELLSPACING=0>
  <TR>
    <TD height="40" background="../images/table2_01.jpg" COLSPAN=2><div align="left">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#FFFFFF" size="-1" face="Verdana, Arial, Helvetica, sans-serif">Log
          In</font></div>
    </TD>
    <TD height="40"><img src="../images/table2_07.jpg" width="16" height="40"></TD>
  </TR>
  <TR>
    <TD width="9" height="83" background="../images/table2_02.jpg">&nbsp; </TD>
    <TD width="507"><form name="form1" method="post" action="?nav=login">
      <div align="center">
        <p>Username: 
            <input name="username" type="text" id="username">
  
          <br>
	    Password:
	    <input name="password" type="text" id="password">	
    </p>
        <p>
          <input type="submit" name="submit" value="Ok">
		  &nbsp;
          <input type="reset" name="Submit2" value="Reset">
        </p>
      </div>
    </form>
      </TD>
    <TD width="16" background="../images/table2_04.jpg">&nbsp; </TD>
  </TR>
  <TR>
    <TD COLSPAN=3> <IMG SRC="../images/table2_05.jpg" WIDTH=528 HEIGHT=17></TD>
  </TR>
</TABLE>
');
?>


Can anyone help? I have played with it for hours and cant seem to log in successfully. It returns my error message. I have made it echo out the pass and username that it receives and checked it against whats in the DB, its the same.

Reply With Quote
  #2  
Old August 4th, 2003, 07:11 PM
laidbak laidbak is offline
you know how we do
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jun 2002
Location: In Tha IE -- San Bernardino COUNTY
Posts: 788 laidbak User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 4 m 2 sec
Reputation Power: 7
Send a message via ICQ to laidbak Send a message via AIM to laidbak Send a message via MSN to laidbak Send a message via Yahoo to laidbak
Try this:
PHP Code:
 $result=mysql_query("SELECT * FROM users WHERE userName='$username' AND userPass='$password'"); 
Mysql likes things quoted.
__________________
__________________________________________________ _
Wil Moore III, MCP | Integrations Specialist | Senior Consultant
Are You Listed...? | DigitallySmooth Inc.

Reply With Quote
  #3  
Old August 4th, 2003, 09:09 PM
pakcik_kantin pakcik_kantin is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Location: Kantin
Posts: 18 pakcik_kantin User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
//When submitted
$_POST['user'] = 'user';
$_POST['password'] = md5('password');


SELECT * FROM users WHERE userName='user' AND userPass='47bce5c74f589f4867dbd57e9ca9f808'

47bce5c74f589f4867dbd57e9ca9f808 is this your password

Reply With Quote
  #4  
Old August 5th, 2003, 09:42 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
It still doesn't work,

Reply With Quote
  #5  
Old August 5th, 2003, 10:34 AM
pakcik_kantin pakcik_kantin is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Location: Kantin
Posts: 18 pakcik_kantin User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
This is your old code
$username=$_POST['username'];
$password=md5($_POST['password']);

$result=mysql_query("SELECT * FROM users WHERE userName=$username AND userPass=$password");

//Try this first
$username=$_POST['username'];
$password=$_POST['password'];

$result=mysql_query("SELECT * FROM users WHERE userName='$username' AND userPass='$password'");

Watch the quote in your query statement, and without md5

Reply With Quote
  #6  
Old August 5th, 2003, 05:55 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
It didn't work either,

Reply With Quote
  #7  
Old August 5th, 2003, 07:51 PM
blindeddie blindeddie is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 1 blindeddie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Instead of this...

if(is_object($result)){
session_start();
session_register('username');

echo("You are now logged in.");


t_redirect("?nav=home","900");}

else{ echo "ERROR: Wrong Username or Password, Please try again, or register, if you haven't.";}


try...

if(mysql_num_rows($result)==1){
session_start();
session_register('username');

echo("You are now logged in.");


t_redirect("?nav=home","900");}

else{ echo "ERROR: Wrong Username or Password, Please try again, or register, if you haven't.";}

this will work as long as all the username and password combinations are unique

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > Help!!!


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