
Originally Posted by
dollar1
Thanks alot , do you think you can share the whole source with me , i would appreciate that .And even if you cant thanks for helping me.
Wrote it from top off my head, should work though.
[highlight="VB.Net"]Private SQLConn as New MySQLConnection("Server=myServerAddress;Database=m yDataBase;Uid=myUsername;Pwd=myPassword;")
Private SQLReader as MySQLReader 'might need as NEW
Private Function MD5HS(ByVal word As String) As String 'MD5HashString
Dim wordBytes As Byte() = Encoding.ASCII.GetBytes(word)
Dim hashedBytes As Byte()
Using md5Crypto As New MD5CryptoServiceProvider()
hashedBytes = md5Crypto.ComputerHash(wordBytes)
End Using
Return String.Join("", hashedBytes.Select(Function(b As Byte) b.ToString("x2")).ToArray())
End Function
Private Function Login(Byval Username As String,Byval Password As String) As Boolean
Dim Success as Boolean
Try
SQLConn.Open
Dim SQLQuery As New MySQLCommand(String.Format("SELECT * FROM users WHERE Username='{0}' AND Password='{1}' LIMIT 1",Username,MD5HS(Password)),SQLConn)
SQLReader = SQLQuery.ExecuteReader
Success = SQLReader.HasRows
SQLReader.Close
SQLConn.Close
SQLCommand.Dispose
Catch ex as MySQLException
SQLConn.Close
Msgbox(ex.tostring)
End Try
Return Success
End Function[/highlight]
PHP Script Sample:
[highlight="PHP"]<?php
$conn = mysql_connect("Server","User","Password")
or die ("Connection failed.");
//connect to the specific database
mysql_select_db("testdb");
$Username = $_GET['Username'];
$Password = $_GET['Password'];
$PW = md5($Password);
if(isset($Username)) {
if(isset($PW)) {
$Query = "SELECT * FROM users WHERE Username='".$Username."' AND Password='".$PW."' LIMIT 1";
$Result = mysql_query($Query);
$Count = mysql_num_rows($Result);
if($Count == 0) {
echo "False"; }
else {
echo "True"; }
} else {
echo "False"; }
}
?>[/highlight]
Url.php?Username=X&Password=Y