[Help] trying to read what is on site

Vb Noob

Member
Joined
Oct 12, 2005
Messages
14
Programming Experience
Beginner
Yes, i have used the 'search' button.

I am a beginner and coding in Visual Basic.net (Visual Studio 2005 Beta)

I am making a login application that detects if access is granted via internet

The link of which I am doing this is;

"www.randomrune.com/auth/valid.php?username="
& Me.txtUser.Text & "&password=" & Me.txtPass.Text

My site returns; "Invalid Password" if the login is incorrect and "Welcome" if the login is correct... I understand the if then, ect for after it finds if access is granted or not... But I am trying to get it to detect the Response (invalid, or welcome) and set it as a string.

Here is what i had

VB.NET:
[SIZE=2][COLOR=#0000ff]If [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]strRESPONSE = "Welcome" [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Then
[/COLOR][/SIZE][SIZE=2]MsgBox([/SIZE][SIZE=2][COLOR=#800000]"Welcome,"[/COLOR][/SIZE][SIZE=2] & [/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].txtUser.Text)
[/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].Hide()
Form2.Show()
[COLOR=#0000ff]ElseIf strRESPONSE = "Invalid Password" then[/COLOR]
[COLOR=#0000ff][COLOR=#000000]MsgBox([/COLOR][SIZE=2][COLOR=#800000]"Invalid Password"[/COLOR][/SIZE][/COLOR][SIZE=2][COLOR=#000000])[/COLOR][/SIZE]
[/SIZE][SIZE=2][COLOR=#0000ff]ElseIf [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].txtUser.Text = [/SIZE][SIZE=2][COLOR=#0000ff]Nothing [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]And [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].txtPass.Text <> [/SIZE][SIZE=2][COLOR=#0000ff]Nothing [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Then
[/COLOR][/SIZE][SIZE=2]MsgBox([/SIZE][SIZE=2][COLOR=#800000]"Please enter a username."[/COLOR][/SIZE][SIZE=2], MsgBoxStyle.Information, [/SIZE][SIZE=2][COLOR=#800000]"Enter a username!"[/COLOR][/SIZE][SIZE=2])
[/SIZE][SIZE=2][COLOR=#0000ff]ElseIf [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].txtUser.Text <> [/SIZE][SIZE=2][COLOR=#0000ff]Nothing [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]And [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].txtPass.Text = [/SIZE][SIZE=2][COLOR=#0000ff]Nothing [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Then
[/COLOR][/SIZE][SIZE=2]MsgBox([/SIZE][SIZE=2][COLOR=#800000]"Please enter a password."[/COLOR][/SIZE][SIZE=2], MsgBoxStyle.Information, [/SIZE][SIZE=2][COLOR=#800000]"Enter a password!"[/COLOR][/SIZE][SIZE=2])
[/SIZE][SIZE=2][COLOR=#0000ff]ElseIf [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].txtUser.Text = [/SIZE][SIZE=2][COLOR=#0000ff]Nothing [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]And [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].txtPass.Text = [/SIZE][SIZE=2][COLOR=#0000ff]Nothing [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Then
[/COLOR][/SIZE][SIZE=2]MsgBox([/SIZE][SIZE=2][COLOR=#800000]"Please enter a username and password"[/COLOR][/SIZE][SIZE=2], MsgBoxStyle.Information, [/SIZE][SIZE=2][COLOR=#800000]"Enter a username + password"[/COLOR][/SIZE][SIZE=2])[/SIZE]
[COLOR=#0000ff]End If[/COLOR]


Ignore the colors if that confuses you :S

Also ignore any syntax errors in the code above, i made it to give you a jist of what i was attempting

If you can help, please reply here, and if you need any more information also reply here.

Thanks in advanced.


 
how exacly are you calling this:
VB.NET:
[SIZE=2][COLOR=#800000] "www.randomrune.com/auth/valid.php?username="[/COLOR][/SIZE][SIZE=2] & [/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].txtUser.Text & [/SIZE][SIZE=2][COLOR=#800000]"&password="[/COLOR][/SIZE][SIZE=2] & [/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].txtPass.Text[/SIZE]
?
 
JuggaloBrotha said:
how exacly are you calling this:
VB.NET:
[SIZE=2][COLOR=#800000]"www.randomrune.com/auth/valid.php?username="[/COLOR][/SIZE][SIZE=2] & [/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].txtUser.Text & [/SIZE][SIZE=2][COLOR=#800000]"&password="[/COLOR][/SIZE][SIZE=2] & [/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].txtPass.Text[/SIZE]
?

not sure what u mean but

if i do

www.randomrune.com/auth/valid.php?username=BOB&password=BOB

see how it returns "Welcome"

and if i do

www.randomrune.com/auth/valid.php?username=BOB&password=BOB90384093

It returns "invalid"

I want it to read that response...
 
Hey,

This will post your data to a script online and return the response. You'd call it as: webResponse = SendBytes("www.randomrune.com/auth/valid.php", "username=BOB&password=BOB")

It may not work as is.. I've just adapted it from my own code but it should give you the idea.

VB.NET:
Public Function SendBytes(ByVal sendURL As String, ByVal sendQuery As String) As String
       
        Dim StrReturn As String = ""

        Dim postData As String = sendQuery

        Dim postDataBytes As Byte() = System.Text.Encoding.ASCII.GetBytes(postData)

        Dim req As System.Net.WebRequest
        Dim reqStream As System.IO.Stream
        Dim res As System.Net.WebResponse
        Dim resStream As System.IO.Stream
        Dim sr As System.IO.StreamReader
        
        Try

                req = System.Net.WebRequest.Create(sendURL)
                req.Method = "POST"
                req.ContentType = "application/x-www-form-urlencoded"
                req.ContentLength = postDataBytes.Length

                reqStream = req.GetRequestStream()

                For lindex = 0 To postDataBytes.Length - 1

                    reqStream.Write(postDataBytes, lindex, 1)

                Next

                reqStream.Close()
                res = req.GetResponse()
                resStream = res.GetResponseStream()

                sr = New System.IO.StreamReader(resStream)
                StrReturn = sr.ReadToEnd()
                sr.Close()
               
            Catch err As Exception
                MsgBox(err.Message & err.Source & err.StackTrace)
            End Try
          
        Return StrReturn

    End Function
 
Back
Top