PHP Coding
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsPHP RelatedPHP Coding

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old October 1st, 2009, 10:50 PM
speckledapple speckledapple is offline
Registered User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Sep 2009
Posts: 20 speckledapple User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 h 40 m 5 sec
Reputation Power: 0
Cannot figure out this problem

I made the changes and still it did not work. So I changed the code completely and rebuilt the statement and the same problem exists. I have no idea whats up. This one has my head scratching. All it says it that the login failed which is the error message I have for a failed login having something to do with counting the rows. argh.

PHP Code:
<?php 
session_start
(); 
error_reporting(E_ALL); 
function 
secure($x)  
{  
   
$x mysql_real_escape_string($x);  
   return 
$x;  
}  
require_once(
'connection.php');  

    if(isset(
$_POST['Login']))  
    {  
        if((
$_POST['username']!='') && ($_POST['password']!=''))  
        {  
              
$username secure($_POST['username']);  
              
$password secure(md5($_POST['password']));  
            
//Use the input username and password and check against table  
            
$qry "SELECT * FROM $tbl_name WHERE username = '$username' AND password = '$password'";               
            
$result=mysql_query($qry); 
     
            
//Check whether the query was successful or not 
            
if($result) { 
                if(
mysql_num_rows($result) == 1) { 
                    
//Login Successful 
                    
session_regenerate_id(); 
                    
$row mysql_fetch_assoc($result); 
                            
$_SESSION['SESS_ID'] = $row['username']; 
                            
$_SESSION['SESS_LNAME'] = $row['lastname']; 
                            
$_SESSION['SESS_FNAME'] = $row['firstname']; 
                            
$_SESSION['SESS_JOINED'] = $row['date']; 
                            
$_SESSION['SESS_EMAIL'] = $row['email']; 
                            
$_SESSION['SESS_CITY'] = $row['city']; 
                            
$_SESSION['SESS_STATE/REGION'] = $row['state/region']; 
                            
$_SESSION['SESS_LOGGED_IN'] = TRUE
                            
header("Location: members.php"); 
                    }else { 
                    
$error 'Login failed'
                } 
            }else { 
                die(
"Query failed"); 
            }  
        }  
        else {  
            
$error 'Please user both your username and password to access your account'
  
        }  
    }  
?>

Reply With Quote
  #2  
Old October 2nd, 2009, 12:15 AM
IAmALlama IAmALlama is offline
Me
Click here for more information. Click here for more information
 
Join Date: Apr 2007
Location: San Diego, CA
Posts: 2,069 IAmALlama User rank is Private First Class (20 - 50 Reputation Level)IAmALlama User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Week 6 Days 7 h 43 m 2 sec
Reputation Power: 5
double check the username and password in the database. double check that the password in the database is also hashed (I've made the mistake of adding the password un-hashed in text to a database). If that doesn't help then try to get more specific with the error. try selecting the password hash and user id out based on just the username and if no rows in the result, then echo "username not found". then compare the posted password hash to the hashed password from the database and if no match then you know the password is the problem. if both pass then you can select out the user based on the user id pulled before with the password. for debugging you can also echo out the password hash from the database and the posted hash to compare them on screen and find out why they aren't matching.

if you need any help with setting this up just ask and I can provide some code if it helps.

Reply With Quote
  #3  
Old October 2nd, 2009, 12:56 AM
speckledapple speckledapple is offline
Registered User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Sep 2009
Posts: 20 speckledapple User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 h 40 m 5 sec
Reputation Power: 0
Ahh I figured it out. It was the password in the database. It was not coded like the result and therefore caused an error in the whole structure. I corrected that. Thanks.

Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP RelatedPHP Coding > Cannot figure out this problem


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




 Free IT White Papers!
 
Create the Optimal Architecture for your Critical Applications
Warburton's the largest independently owned bakery in the UK faced a number of difficult challenges in providing the most robust yet efficient IT infrastructure for their organization's success. IBM's services combined with their xSeries servers created the perfect platform for their SAP environment with sufficient flexibility, and did so in very time effective fashion.

Request Your Free Technology Downloads!
 
Five Best Practices for Deploying a Successful Service-Oriented Architecture
This white paper describes the benefits you can expect with SOA, and how IBM can help take your business there.

Request Your Free Technology Downloads!
 
Gartner Magic Quadrant for Application Delivery Controllers
Gartner summarizes its view on Application Delivery Controllers, evaluates strengths and weaknesses of solutions, and provides Magic Quadrant reporting for a quick comparison across all vendors. Learn from Gartner how you can benefit from an all-in-one device like Citrix NetScaler that delivers the highest levels of availability, performance and security.

Request Your Free Technology Downloads!
 
Knowledge is Power
What you don't know can hurt you, and is likely costing you money and increasing your security risks during an era of scarce resources. This white paper proposes six key strategies that enterprise security managers can use to improve their network defense posture.

Request Your Free Technology Downloads!
 
Rationalizing the Multi-Tool Environment
The rationalized multi-tool approach is flexible, scalable and cost effective. It provides the necessary input to the IT service management business processes. It preserves prior investments in monitoring tools, empowers technologists to select the best tools with which to do their jobs, and enhances effective response to incidents.

Request Your Free Technology Downloads!
 

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




© 2003-2010 by Developer Shed. All rights reserved. DS Cluster 1 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek