我想制作一个使用php/my sql的Windows Phone 8登录功能的应用程序。
我有以下php脚本:
在我的Windows Phone C#单击事件中,我写了以下内容:
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("Test@test.com"));
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));
}
}
}
我验证了电子邮件和密码的正确性,使用我放置的 C# 代码,但最终我总是收到类似于以下消息的信息:
e.Result =“用户名或密码不正确”
。