I'm trying to make an application in windows phone 8 login functionality using php/my sql
i have following php script :
in my windows phone c# click event i wrote following things :
private void btnLogin_Click(System.Object sender, System.Windows.RoutedEventArgs e)
{
Uri uri = new Uri(url, UriKind.Absolute);
StringBuilder postData = new StringBuilder();
postData.AppendFormat("{0}={1}", "email", HttpUtility.UrlEncode("[email protected]"));
postData.AppendFormat("&{0}={1}", "pwd1", HttpUtility.UrlEncode("password"));
WebClient client = default(WebClient);
client = new WebClient();
client.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
client.Headers[HttpRequestHeader.ContentLength] = postData.Length.ToString();
client.UploadStringCompleted += client_UploadStringCompleted;
client.UploadProgressChanged += client_UploadProgressChanged;
client.UploadStringAsync(uri, "POST", postData.ToString());
prog = new ProgressIndicator();
prog.IsIndeterminate = true;
prog.IsVisible = true;
prog.Text = "Loading....";
SystemTray.SetProgressIndicator(this, prog);
}
private void client_UploadProgressChanged(object sender, UploadProgressChangedEventArgs e)
{
//Me.txtResult.Text = "Uploading.... " & e.ProgressPercentage & "%"
}
private void client_UploadStringCompleted(object sender, UploadStringCompletedEventArgs e)
{
if (e.Cancelled == false & e.Error == null)
{
prog.IsVisible = false;
string[] result = e.Result.ToString().Split('|');
string strStatus = result[0].ToString();
string strMemberID = result[1].ToString();
string strError = result[2].ToString();
if (strStatus == "0")
{
MessageBox.Show(strError);
}
else
{
NavigationService.Navigate(new Uri("/DetailPage.xaml?sMemberID=" + strMemberID, UriKind.Relative));
}
}
}
i verfity the email and password is correct, in c# code, which i put, but in the end i always get message like this : e.Result = "Incorrect username or password"
I downloaded your app sample and tested it. When i examin the request the app is sending using Fiddler, it seams that the app is sending the exactly the info you provided. So your POST method is doing it job.
I tested even to resend the request from inside Fiddler and get the same result, ie. Correct POST info but wrong e.Result (Incorrect username or password).
All this makes me feel that the problem is not in your app or WebClient other than server side. Please look at it.
By the way why using WebClient? you can user HttpWebRequest or HttpClient.
you can try and use like this
client.Credentials = new NetworkCredential(usename, password);
i think this might correct you problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With