Login Register






Thread Rating:
  • 1 Vote(s) - 5 Average


Tutorial Basic Login w/ PHP filter_list
Author
Message
Basic Login w/ PHP #1
Hey there SL, today I'm going to show you how to make a super basic login system using PHP. First of all, open a new form and add: 3 Labels, 2 Textbox's and 1 button to your form. It should look like this:

[Image: etAC.png]

Next, you want to double click on the button and paste this code which I will explain. Above Public Class Form1 you want to put:
Code:
Imports System.Net
After you do that, paste this code under the button click event.
Code:
Dim url As String = "http://www.yourwebsite.com/" 'This is the baseURL for your website. Remember to leave the slash!
        Dim wc As New WebClient
        Dim result As String = wc.DownloadString(url & "login.php?username=" & TextBox1.Text & "&password=" & TextBox2.Text) 'This will download the results of the page from your PHP file checking the username and password you have just submitted to the server.
        If result = "1" Then 'If its right
            MsgBox("You have succesfully logged in!", MsgBoxStyle.Information)
            Label3.Text = "Status.... logged in!"
        Else 'If its wrong
            MsgBox("An error has occured, please try again!", MsgBoxStyle.Critical)
            Label3.Text = "Status.... error occured!"
        End If

Next edit where it says "yourwebsite.com/" to the url of your website. You are done with the visual basic portion now!



Alright, now we start the PHP section.

Code:
<?php
$username = $_GET['username']; //Set the username
$password = $_GET['password']; //Set the password

if($username == "admin" && $password == "test")  { //This line will check and see if the username and password you submitted are correct
    echo "1"; //If correct display 1
} else {
    echo "2"; //Else display 2
}
?>
Paste that in to a new file and save it as login.php, upload it to the website you set in the visual basic app.

I have explained each line in the PHP code if you don't know what your doing.

Now all thats left to do is run your app and enter in the username and password, if you did it all right you should see this:

[Image: c4ll.png]

If you did something wrong you will see this:
[Image: nqh9.png]


If you have any questions feel free to ask!
[Image: GiXvY27.png]

Reply

RE: Basic Login w/ PHP #2
Looks good Sap! I would recommend adding some more security measures to this, like UserAgents or special POST data that is required. Also be sure to escape sequence any data received through requests to avoid MySQLi, and make sure you hide that WebRequest fairly well. Other than that, it looks good. Smile

Reply

RE: Basic Login w/ PHP #3
(05-18-2013, 03:12 AM)xZ3ROxPROJ3CTx Wrote: Looks good Sap! I would recommend adding some more security measures to this, like UserAgents or special POST data that is required. Also be sure to escape sequence any data received through requests to avoid MySQLi, and make sure you hide that WebRequest fairly well. Other than that, it looks good. Smile

You can never avoid me!

Reply

RE: Basic Login w/ PHP #4
(05-18-2013, 05:21 AM)SQLi Wrote: You can never avoid me!

I can figure out something to make my systems less susceptible to SQLi attacks. I'll NEVER beat you, but I'll definitely get close. Wink

Reply







Users browsing this thread: 2 Guest(s)