Go Back   PCMech Forums > Help & Discussion > Web Design / Development

Need Some Help? Type Your Keywords Here:

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Old 12-01-2005, 04:45 PM   #1
Chop Chop
 
catacon's Avatar
 
Join Date: Jan 2005
Location: St. Louis, MO
Posts: 1,035
Send a message via AIM to catacon Send a message via Yahoo to catacon
PHP/MySQL Help

Hey,

I am using a login script for my website that I wrote for a former site. On that site it worked, but now it won't. When I try to login it says that the information is not valid (which it is). The code is below. I was wonder what I doing wrong.

I am using phpMyAdmin for creating the databases and was wondering if that could cause problems. I saw a new setting that says "Collation" and it is set to latin-swedish. I have never used that in previous version and thought that could be causing this. Any help would be appreciated. Thanks!

PHP Code:

<?php

if (isset($_POST['submit'])) {
    require_once (
"../mysql_connect.php");

// Check Username
    
    
if (empty($_POST['username'])) {
        
$u FLASE;
        echo 
"Please enter your username.";
    } else {
        
$u escape_data($_POST['username']);
    }
    
// Check Password

    
if (empty($_POST['password'])) {
        
$p FLASE;
        echo 
"Please enter your password.";
    } else {
        
$p escape_data($_POST['password']);
    }
    
    if (
$u && $p) { //All is well
        
$query "SELECT user_id, username, time_offset FROM members WHERE username='$u' AND password=PASSWORD('$p')";
        
$result = @mysql_query ($query);
        
$row mysql_fetch_array ($resultMYSQL_NUM);
        
        if (
$row) { // Match was made
        
            
$_SESSION['time_offset'] = $row[2];
            
$_SESSION['username'] = $row[1];
            
$_SESSION['user_id'] = $row[0];
            
            if (isset(
$_POST['remember'])) {
                
setcookie ("cooktime"$row[2], time()+60*60*24*30"/");
                
setcookie ("cookname"$row[1], time()+60*60*24*30"/");
                
setcookie ("cookuser"$row[0], time()+60*60*24*30"/");
            }
            
            
$update "UPDATE members SET last_activity=NOW(), loggedin='1' WHERE user_id={$row[0]}";
            
$result = @mysql_query($update);
            
            if (
$result) { //worked 
                        
            
ob_end_clean();
            
            
header ("Location: http://" $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . "/main.php");
            exit();
            
            }
            
        } else {
            echo 
"Information entered did not match those in our database.";
        }
        
        
    } else {
        echo 
"Please try again."
    }
}

?>

<span class="title">Login</span>


Your browser must allow cookies in order for you to login.




<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">

Username: <input type="text" name="username" size="10" maxlength="20" value="<?php if(isset($_POST['username'])) { echo $_POST['username']; } ?>" />




Password: <input type="password" name="password" size="10" maxlength="16" />




Forget Me Not: <input type="checkbox" name="remember" />



<center><input type="submit" name="submit" value="Login" /></center>

</form>
__________________
Main Computer: Intel Core i5 2500K | AsRock Extreme3 Z68 | Corsair Vengeance 2 x 4GB DDR3 1600 | EVGA GTX460 768MB | Western Digital Caviar 750GB 7200RPM SATAII | Mushkin 60GB SSD w/ SRT enabled | Asus 20X DVD Burner | Antec 550W Modular | Cooler Master HAF 912 w/ 4 fans | NXZT Sentry Mesh fan controller | W7 | 2 x 23" LG IPS Monitors

Laptop: Asus EEE 1000HE | 2GB RAM | Ubuntu

Laptop: Lenovo Thinkpad T60p | 4GB RAM | W7
catacon is offline   Reply With Quote
Old 12-01-2005, 05:34 PM   #2
Wx geek
 
blue60007's Avatar
 
Join Date: Aug 2005
Location: Indiana
Posts: 6,638
What information is invalid? Can you give us an exact error message?
__________________
"It is the way of man to make monsters and it is the nature of monsters to destroy their makers."
blue60007 is offline   Reply With Quote
Old 12-01-2005, 05:48 PM   #3
Chop Chop
 
catacon's Avatar
 
Join Date: Jan 2005
Location: St. Louis, MO
Posts: 1,035
Send a message via AIM to catacon Send a message via Yahoo to catacon
Well, it's the message I put in there if the password and/or username do not match. After the query it says if($row), if that is not true, the message "Information entered did not match those in our database." There is no mysql error.
catacon is offline   Reply With Quote
Old 12-01-2005, 05:51 PM   #4
Wx geek
 
blue60007's Avatar
 
Join Date: Aug 2005
Location: Indiana
Posts: 6,638
Well it sorta sounds like something was changed during a MYSQL and/or PHP upgrade... I might try to duplicate that database and try connecting to it with a duplicate.
blue60007 is offline   Reply With Quote
Old 12-30-2005, 06:47 PM   #5
Member (7 bit)
 
Join Date: Dec 2005
Posts: 87
Try changing all the $result = @mysql_query ($query); to $result = @mysql_query ($query) or die(mysql_error()); This will give you the specific error from the MySQL on what's going wrong.

I bet it is a simple connection problem. Did you change your settings to the new db?
hartken is offline   Reply With Quote
Reply

Bookmarks

Still Need Help? Type Your Keywords Here:


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

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 05:01 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
SEO by vBSEO 3.6.0 PL2