Page 2 of 2 FirstFirst 12
Results 11 to 15 of 15
  1. #11
    Junior Member
    Join Date
    Dec 2009

    Re: Login System, combined with PHP - C# - MySQL

    Quote Originally Posted by FreckleS View Post
    Not right now, I have 10 stitches in my elbow and I am going on holidays.
    Alrights, Than ill wait in patience =) Have nice holidays ^^

  2. #12
    Junior Member
    Join Date
    Aug 2007
    Czech Republic

    Re: Login System, combined with PHP - C# - MySQL

    Hi! Its a pitty u havent understand my explain, but how freckles said u want to seend request to web and get response and there i have problem too I am sending request by webbrowser.navigate like i posted before but i want to know how to send request that i will be able to get some response (i.e.: wich products he have bought and if the pass and user was correct etc) [this points to u freckles coz u looks that u know how xD] I need help now too xD....


  3. #13
    Join Date
    Apr 2006
    AL, USA

    Re: Login System, combined with PHP - C# - MySQL

    You do not want to use a web browser control to try and programmatically retrieve and submit data.
    That is just not what that particular control is for. (Stupid control tbh)

    Here is a small example. This is by no means secure or crack proof, but at least something to get you started.

    Make a new c# winforms project with 2 textboxes and a button.
    The textboxes should be named "txtUser" and "txtPass".
    The button should be named "btnLogin"
    Of course, you could name them whatever you want, but that's just what I referred to them as in the pasted code.
    Delete anything in FORM1.CS (under code view):

    PHP Code:
    using System.Security.Cryptography;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Windows.Forms;
    using System.Drawing;
    using System.Data;
    using System.Linq;
    using System.Text;
    using System.Net;
    using System.IO;
    using System;

    partial class Form1 Form

    string GetMD5(string StrToHash)
    byte[] hash MD5CryptoServiceProvider.Create().ComputeHash(Encoding.ASCII.GetBytes(StrToHash));
    StringBuilder str = new StringBuilder();
    byte b in hash)

    void doLogin()
    ASCIIEncoding encoding = new ASCIIEncoding();
    string DataToPost "user=" txtUser.Text "&pass=" GetMD5(txtPass.Text);
    byte[] data encoding.GetBytes(DataToPost);
    StringBuilder sb = new StringBuilder();

    //Setup a web request. This is our programmatic connection to the website.
    HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://skynet-nix1/testing/auth.php");
    //Tell it we are going to post some data.
    request.Method "POST";
    //From a FORM.
    request.ContentType "application/x-www-form-urlencoded";
    //And tell it how much data to expect (This can be used to upload data.....)
    request.ContentLength data.Length;
    //Get a stream for our connection so we can write.
    Stream sendStream request.GetRequestStream();
    //Send our data out.
    // Read buffer.
    byte[] bRead = new byte[8192];

    //See what got returned.
    HttpWebResponse response = (HttpWebResponserequest.GetResponse();

    //Read stream.
    Stream resStream response.GetResponseStream();

    //Used for data operations bewlow.
    string tempString null;
    int count 0;

    //Fill our buffer.
    count resStream.Read(bRead0bRead.Length);

    //Check to see if we got a response.
    if (count != 0)
    //We dont need byte data.
    tempString Encoding.ASCII.GetString(bRead0count);
    //Add current ascii to our response string.
                while (
    count 0); // Loop until we are out of data.

    if (sb.ToString() == "Hello")
    MessageBox.Show("Login Successful");
    MessageBox.Show("Login Failed");

    void btnLogin_Click(object senderEventArgs e)

    Auth.php looks like:
    PHP Code:

    require 'dbconnect.php';


    $myusername stripslashes($myusername);
    $mypassword stripslashes($mypassword);
    $myusername mysql_real_escape_string($myusername);
    $mypassword mysql_real_escape_string($mypassword);

    $sql="SELECT * FROM test_users WHERE username='$myusername' and password='$mypassword'";
    "Invalid login."
    And dbconnect.php looks like:
    PHP Code:
    $dbName "SKY_TEST";
    $dbUser "testuser";
    $dbPass "testpass";

    $con mysql_connect($dbServer$dbUser$dbPass) or die(mysql_error());
    mysql_select_db($dbName) or die(mysql_error());

    To extend this and secure it, you may want to consider SSL, using a replace algorithm on the md5 hashing, challenge strings, a hwid hash, etc etc.

    Hope this helps either way.

  4. #14
    VIP FreckleS's Avatar
    Join Date
    Jan 2007

    Re: Login System, combined with PHP - C# - MySQL

    back guys, if you still need any help let me know, you shouldn't cause skyline covered it great!
    "The pain you feel today, will be the strength you feel tomorrow"

  5. #15
    Junior Member scuter's Avatar
    Join Date
    May 2013

    Re: Login System, combined with PHP - C# - MySQL

    I know that this thread is very old, but I need support for that. I made everything like in the tutorial above but it instantly says "Access Denied", even with the correct userdata :|

Page 2 of 2 FirstFirst 12

Similar Threads

  1. [PHP]Snippet - MYSQL
    By sil#s in forum Html, Php, Xml, Css, ...
    Replies: 4
    Last Post: July 8th, 2010, 19:31
  2. Replies: 2
    Last Post: June 7th, 2010, 14:45
  3. [TUT]C# SIMPLE login system
    By nowolu in forum Tutorials
    Replies: 0
    Last Post: May 2nd, 2010, 18:41
  4. Offering help on Mysql, php and css
    By michael1987 in forum Html, Php, Xml, Css, ...
    Replies: 1
    Last Post: January 27th, 2009, 19:40
  5. Log in at website (MySQL?)
    By Square in forum Html, Php, Xml, Css, ...
    Replies: 6
    Last Post: December 8th, 2008, 18:39


Posting Permissions

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