Ich hab mich jetzt bei einem Webserver von
[Only registered and activated users can see links. Click Here To Register...] angemeldet. Nun hab ich auf meine Website die Datei login.php und register.php hochgeladen.
Bei dem Programm:
Code:
Imports System.Collections.Specialized, System.Net
Imports System.Text
Imports System.Security.Cryptography
Public Class Form1
Dim nv As New NameValueCollection
Dim wc As New WebClient
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles reg.Click
nv.Clear()
nv.Add("u", reg_usr.Text)
nv.Add("pw", MD5StringHash(reg_pw.Text))
nv.Add("e", reg_email.Text)
nv.Add("o", "1")
Dim result() As Byte = wc.UploadValues("http://localhost/register.php?", "POST", nv)
Dim resultstring As String = System.Text.Encoding.ASCII.GetString(result)
MessageBox.Show(resultstring)
End Sub
Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles chkav.Click
nv.Clear()
nv.Add("u", reg_usr.Text)
nv.Add("o", "0")
Dim result() As Byte = wc.UploadValues("http://localhost/register.php?", "POST", nv)
Dim resultstring As String = System.Text.Encoding.ASCII.GetString(result)
MessageBox.Show(resultstring)
End Sub
Private Sub btn_login_Click(sender As System.Object, e As System.EventArgs) Handles btn_login.Click
nv.Clear()
nv.Add("u", log_usr.Text)
nv.Add("pw", MD5StringHash(log_pw.Text))
Dim result() As Byte = wc.UploadValues("http://localhost/login.php?", "POST", nv)
Dim resultstring As String = System.Text.Encoding.ASCII.GetString(result)
MessageBox.Show(resultstring)
End Sub
Public Function MD5StringHash(ByVal strString As String) As String
Dim MD5 As New MD5CryptoServiceProvider
Dim Data As Byte()
Dim Result As Byte()
Dim Res As String = ""
Dim Tmp As String = ""
Data = Encoding.ASCII.GetBytes(strString)
Result = MD5.ComputeHash(Data)
For i As Integer = 0 To Result.Length - 1
Tmp = Hex(Result(i))
If Len(Tmp) = 1 Then Tmp = "0" & Tmp
Res += Tmp
Next
Return Res
End Function
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
End Class
Habe ich die Links so angepasst:
Code:
Dim result() As Byte = wc.UploadValues("http://homepage.ad.funpic.de/login.php?/", "POST", nv)
Doch wenn ich das Programm dann debugge kommt:
Code:
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-16106315-4']);
_gaq.push(['_setDomainName', '.funpic.de']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript';
ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' :
'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(ga, s);
})();
</script>
Den Datenbank-Connectionstring habe ich natürlich angepasst.
Kann mir da vllt. jemand weiterhelfen?
#edit:
login.php
PHP Code:
<?php
$userpw = mysql_real_escape_string($_POST['pw']);
$userid = mysql_real_escape_string($_POST['u']);
@mysql_connect('localhost', 'root', '') or die (mysql_error());
@mysql_select_db('vb') or die (sqlerror(mysql_errno(), mysql_error()));
$query = "SELECT * FROM `user` WHERE `user`='$userid' AND `passwd`='$userpw'";
$result = mysql_query($query);
$resultcount = mysql_num_rows($result);
if ($resultcount == 0)
{
echo 'Login fehlgeschlagen';
}else {
echo 'Erfolgreich eingeloggt';
}
?>