Red Security
vb.net php database login - Printable Version

+- Red Security (https://redsecurity.info/cc)
+-- Forum: Programming (https://redsecurity.info/cc/forumdisplay.php?fid=5)
+--- Forum: Visual Basic & .NET Framework (https://redsecurity.info/cc/forumdisplay.php?fid=17)
+--- Thread: vb.net php database login (/showthread.php?tid=1650)



vb.net php database login - viruss - 11-12-2020

Code:
<?php

/* Connent Database */
$con = new mysqli('localhost', 'dbuser', 'db password', 'dbname');
$con->set_charset('utf-8');
if ($con->connect_error) {
    die($con->connect_error);
}

$action = ($_GET['action'] != null) ? $_GET['action'] : null;
$username = ($_GET['username'] != null) ? $_GET['username'] : null;
$password = ($_GET['password'] != null) ? $_GET['password'] : null;



if ($action != '' && $username != '' && $password != '') {
    switch ($action) {
        case 'register':
            $result = $con->query("SELECT * FROM member WHERE username='{$username}'");
            if ($result->num_rows == 0) {
                $con->query("INSERT INTO make_your_table_name (username,password) VALUES ('{$username}','{$password}')");
                echo 'success';
            } else {
                echo 'Plase Try Again.';
            }
            break;
        case 'login':
            $result = $con->query("SELECT * FROM grabinfo WHERE username='{$username}' AND password='{$password}'");
            if ($result->num_rows > 0) {
                echo 'success';
            } else {
                echo 'incorrect';
            }
            break;

        default:
            echo 'invalid action';
            break;
    }


}

vb.net code
2 textboxes 2 buttons
button1 text reg_user
button2 name login_user
textbox1.text
textbox2.text
form1.vb

Code:
Public Class Form1

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim webbrowser1 As New WebBrowser
        webbrowser1.Navigate("https://haxcore.net/try10/reg_user.php?action=register&username=" & TextBox1.Text & "&password=" & TextBox2.Text)

        Do While webbrowser1.ReadyState <> WebBrowserReadyState.Complete
            Application.DoEvents()
        Loop
        If webbrowser1.DocumentText.Contains("success") Then
            MessageBox.Show("User successfully registered, you can now log in", "E-mail / username already exists", MessageBoxButtons.OK, MessageBoxIcon.Error)

            ' Me.Hide()
        ElseIf webbrowser1.DocumentText.Contains("FINISHED") Then
            MessageBox.Show("This e-mail and / or the username already exists in our database!", "Registration successful", MessageBoxButtons.OK, MessageBoxIcon.Information)
        End If
    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        Dim wClient As New System.Net.WebClient
        Dim result As String = wClient.DownloadString("https://haxcore.net/try10/reg_user.php?action=login&username=" + TextBox1.Text + "&password=" + TextBox2.Text)
        If result = "success" Then
            MessageBox.Show("Login Success", "", MessageBoxButtons.OK, MessageBoxIcon.Information)
        Else
            MessageBox.Show("Username And Password Incorrect.", "", MessageBoxButtons.OK, MessageBoxIcon.Warning)
        End If
    End Sub
End Class

reg_user output
   

login_user output
   

got to line number 24 in form1.vb hit enter use arrow key up then add form2.show