Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 05-24-2005, 04:30 PM PHP Login Help
Novice Talker

Posts: 5
Trades: 0
Hay im new here and i would like some help, im working on a php login script for flash. I had it working to start with but i have changed my registration script so the password is now md5 encrypted. Can some one tell me what i need to edit on the code bellow to make the login work again. Thanks Space-Cowboy

Code:
<? 

//Database Connectivity Variables//

$DBhost = "localhost";
$DBuser = "joj_test";
$DBpass = "test";

$db_name = "joj_stargate";
$login_table = "Users"; 


//Create a connection to the MySQL Database//

$connection = @mysql_connect($DBhost,$DBuser,$DBpass) or die("Couldn't Connect.");
$db = @mysql_select_db($db_name, $connection) or die("Sorry, I could not select the requested Database ");

//SQL Querys
$sql = "SELECT * FROM $login_table WHERE Username = \"$username\" and Password = \"$password\"
";

$result = @mysql_query($sql, $connection) or die("Couldn't execute query.");



/*Now checking for the results of the query. if the results are not equal to zero then everything ok, anything else then the authentication failed*/

$num = mysql_num_rows($result); 

if ($num != 0) { 
 
   
// Send Results Back To Flash //  

echo "status=Authentication Accepted"; 
echo "&chklogin=good";
echo "username=$username";
echo "address=$adres";
exit;  
}
else {
// Send Errors Back To Flash //
 echo "chklogin=bad";
 echo "&status=Athentication Failed";  
}

?>
Space Cowboy is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 05-24-2005, 04:56 PM
stoot98's Avatar
Ultra Talker

Posts: 427
Name: Stuart
Location: Glasgow, Scotland
Trades: 0
This may be way off - I only know the way I would write the same bit of code so there may be others ways/syntax so if its not this then ignore me.

I don't really know what the '@' signs are all about....

In the query I dont know if you really need to use the forward slash before the quote.

I THINK this is the problem though, you should use a single quote ' instead of double " because otherwise its taking the $username as a string and not a variable.

Hope this helps, otherwise boot my arse
stoot98 is offline
Reply With Quote
View Public Profile
 
Old 05-24-2005, 05:09 PM
Novice Talker

Posts: 5
Trades: 0
well it worked using that code before. THe only problem is i dont know how to make it work with a MD5 password!
Space Cowboy is offline
Reply With Quote
View Public Profile
 
Old 05-24-2005, 05:12 PM
pushedtomb's Avatar
Super Talker

Posts: 100
Name: Nathen
Location: Casnewydd, De Cymru, UK
Trades: 0
should say in there http://uk.php.net/manual/en/function.md5.php
__________________

Please login or register to view this content. Registration is FREE


Quote:
- "I've often wondered how MS can say that other software "isn't compatible" with MS when MS stuff isn't even compatible with other MS stuff" - quote from Daily Thing.com
pushedtomb is offline
Reply With Quote
View Public Profile
 
Old 05-24-2005, 05:26 PM
Novice Talker

Posts: 5
Trades: 0
Yep that helped pritty easy thanks.
Space Cowboy is offline
Reply With Quote
View Public Profile
 
Old 05-24-2005, 08:04 PM
0beron's Avatar
Defies a Status

Posts: 1,832
Location: Somewhere else entirely
Trades: 0
Just to clear some things up :
the @ signs supresses errors on function calls - so if the query fails you don't get a nasty error. This is usually a security measure since the standard SQL error is along the lines of 'mySQL error... blah blah version number blah blah ... using password: no blah blah....', containing info you don't want people to see so easily.

" double quotes " cause variables to expand out to their values, whereas ' single quotes ' ignores the variable and puts $varname straight into the string. When putting string values into mySQL however, you need to put single quotes around them:

PHP Code:
 mysql_query("INSERT INTO table VALUES('$stuff')"); 
This is OK since the string as a whole is in double quotes, so the variable $stuff expands, and the single quotes are taken literally and included in the output.
__________________
UPDATE 0beron SET talkupation = talkupation + lots WHERE post = 'helpful';

Please login or register to view this content. Registration is FREE
(aka MSN handwriting for forums)
0beron is offline
Reply With Quote
View Public Profile Visit 0beron's homepage!
 
Reply     « Reply to PHP Login Help
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.18091 seconds with 12 queries