Results 1 to 6 of 6
  1. #1
    Join Date
    Jul 2011
    Posts
    4

    Question Unanswered: Connecting VB, to php & MySQL?

    Hi all,

    I am a beginner in PhP and mysql.
    I am having trouble with connecting my Visual Basic Windows Program, to my php script.

    I am using Visual Studio 2010 and i am having serious troubles with this code.

    Heres My Code

    PHP Code:

    <?PHP

    //Database Information

    $dbhost = "localhost";
    $dbname = "MYDATABASE";
    $dbuser = "MYDETAILS";
    $dbpass = "MYPASS";

    //Connect to database

    mysql_connect ( $dbhost, $dbuser, $dbpass)or die("Could not connect: ".mysql_error());
    mysql_select_db($dbname) or die(mysql_error());

    $username = $_GET['username'];
    $query = "INSERT INTO users2 (username) VALUES ('$username' )";
    $result = mysql_query($query);
    $rows = mysql_affected_rows($result);
    echo "good";
    ?>

    VB Code:

    Public Class Register

    Dim Downloaded As Object
    Dim INetControl As Object


    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSave.Click
    Downloaded = INetControl.OpenURL("http://76.164.196.202/~evenbala/sqltest.php?username=" & username1.Text)
    End Sub
    End Class

    My vb code, was taking from another post for vb6, i think. Basically what im looking to do is make a register form and soon a login form.... Connected to my websites database. And since my host doesnt have remote MySQL setup i am having a "ball ache" with this.

    Please Help Me With This, Before I Have No Hair Left

  2. #2
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    All that PHP script does is dump usernames into a database.

    Why are you writing stuff in vb6 and smashing it against a php/mysql application? This sounds like you're trying to pound nails with an allen wrench. What's the project you're working on right now? There are several potential issues with your current approach wherein you're using unsanitized GETvariables from VB6 via COM automation, but I'm not sure they're worth addressing until I know more about the problem you're trying to solve and why you're using these specific technologies in the first place...
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  3. #3
    Join Date
    Jul 2011
    Posts
    4
    Hi mate,

    Well this is my very first vb project if you like. What i am aiming to do is make a program that i can register through and login. I have a website, and i want to be able to use login information from the MySQL database into my program.

    So in short,

    *My program needs access to a remote MySQL database*
    *Be able to Register and Login using info from the Users table*

    I have followed a video tut that shows how to do it, but im not using a localhost and my webhost provider doesnt support "remote MySQL"

    Which left me searching endlessly for hours, and picked up little bits of info, in what i though may have helped.

    Hope this kind of gives you an insight as to where im trying to go mate and look forward to your reply

    Regards,
    Geordie

  4. #4
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    k, couple things...

    Is this an existing website or are you building it from scratch right now? What does the website do? What does this desktop application do that the website doesn't? How are they related to each other? More directly, why do you need to build both a website AND a desktop application?

    Why VB6 as opposed to VB.NET? VB.NET could offer you quite a few choices and tools for dealing with identity management. VB6 is at least unofficially deprecated. I don't know if it has been formally end-of-lifed, but it certainly isn't the recommended platform for new projects.

    Is there anything preventing you from accessing your MySQL database directly as opposed to trying to automate a PHP script? VB6/VB.NET/etc can all connect to MySQL in roughly the same way that PHP connects to it. You don't have to stick PHP in the middle. Is there a reason you chose that route?
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  5. #5
    Join Date
    Jul 2011
    Posts
    4
    Well the website is all coded in html and only register and login have php behind them to create my users table.

    So the only thing the program and my website will have in common atm, is the register and the login, using the MySQL users table. I am looking to create a simple anticheat program that scans for hack/cheats takes screenshots etc.

    I havent a clue as to what vb i am using , I am using microsofts visual studios 2010, as there are alot of tuts for VS2010 on the kind of stuff i would like in my program.

    As for "Is there anything preventing you from accessing your MySQL database directly as opposed to trying to automate a PHP script?" Yes my webhost provider has blocked remote access to the MySQL server, they say hackers attack it so much so they block the port 3306.

    I would be open to trying other things, if possible. Once i have over come this Blip and learnt a bit, i will be looking to add more features that use MySQL database.

    Thanks for replying

  6. #6
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    What does the website DO? Why do people log in to it? What does it do for them?

    I'd be incredibly wary of any software that "scans" my computer and takes screen shots while communicating secure credentials to a 3rd party website. I'll assume you have all of those problems worked out.

    I would probably solve this by exposing a secure web service. Going from not knowing what version of VB you're using to secure web service architecture is going to be more than a little blip, fair warning...

    The basic idea is you have a web service that communicates xml back and forth between your website and whoever wants to talk to it. In this case "whoever wants to talk to it" would be your desktop application. The web service listens for incoming xml, parses it out and decides what to do. The service could be a PHP script, .NET service, etc. Just so long as you can send it specifically formatted xml that tells it what to do, and receive formatted xml with the data you want back.

    If, for instance, the web service is an identity management service, it might receive a request to validate whether a username/password is correct. The service will receive the username/password as xml, decide it has to go to the database to validate the credentials, and then emit xml back to the caller. The caller than has to parse the xml it received from the web service to determine what the answer was.

    That was a simplified example, but hopefully enough to get the picture.

    I strongly, STRONGLY recommend going through a lot of basic tutorials before trying to hack this together. Once you have the basic concepts down, VB.NET can do a lot of the heavy lifting for you on the desktop app side. It's important to understand what it's doing for you before deploying something like this to the internet though. I'm not very familiar with PHP so I don't know how painful it will be to write your service there. That's why asked how far along you are with your website. .NET has facilities to write the irritating parts of the service for you, complete with out-of-the-box authorization and authentication providers.

    I'll be blunt. The fact that you copy and pasted VB6 code into a .NET application and passed unsecured credentials via GET parameters to an unsecured, unsanitized PHP script does not bode well...
    Last edited by Teddy; 07-21-11 at 17:09.
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •