0

I have been battling a few days to pass variables from C# Windows Form Application to a PHP Web-Service. After numerous tests I concluded that the variables from the Windows Form Application does not reach the PHP Web-Service.

It seems like my method of passing variable is not correct.

A bit of background on the variables: When the user login to the Windows Form Application, the username, password and a unique software token is send to the Web-Service for validation from my database.

I suspect my problem is in the way I structure the URL.

Here is my C# Code:

var Token = "Token Number";
var username = txtusername.Text;
var password = txtpassword.Text;

        try
        {
            WebRequest request = WebRequest.Create("https://mydomain.com.au/LoginVerification.php?username=username&password=password&Token=Token");
            request.Method = "GET";
            WebResponse response = request.GetResponse();
            Stream dataStream = response.GetResponseStream();
            // Open the stream using a StreamReader for easy access.  
            StreamReader reader = new StreamReader(dataStream);
            // Read the content.  
            var responseFromServer = reader.ReadToEnd();
            MessageBox.Show(responseFromServer.ToString());
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.ToString());
        }
1
  • You should hide the contents of that token. You just gave everyone on the internet the ability to google your security token. Commented Dec 19, 2018 at 0:11

1 Answer 1

1

You're just passing the literal hard-coded values "username" and "password", not the contents of the variables.

Try concatenating the variables into the URL instead:

WebRequest request = WebRequest.Create("https://mydomain.com.au/LoginVerification.php?username=" + username + "&password=" + password + "&Token=" + Token);
Sign up to request clarification or add additional context in comments.

2 Comments

Probably want to do the same with Token
@ADyson - A more semantically accurate description of the problem is that the OP is passing literal values. Static means something different entirely.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.