好吧。我對於我的生活無法弄清楚爲什麼登錄頁面代碼不起作用。也許我錯過了什麼。如果你需要完整的源代碼,我很樂意給它。我試圖讓用戶名與列表比較,找到它的密碼,然後與文本框中的密碼進行比較。那麼如果密碼匹配。重定向到帳戶頁面。網站登錄頁面無效
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Configuration;
namespace Vanguardian_Tournaments
{
public partial class Login : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void LoginBTN_Click(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["RegistrationConnectionString"].ConnectionString);
conn.Open();
string ckUser = "Select Count(*) from UserData where CFAName = '" + LoginTB.Text + "'";
SqlCommand cfaComm = new SqlCommand(ckUser, conn);
int temp = Convert.ToInt32(cfaComm.ExecuteScalar().ToString());
conn.Close();
if (temp == 1)
{
conn.Open();
string ckPass = "Select Password from UserData where CFAName = '" + LoginTB.Text + "'";
SqlCommand PassComm = new SqlCommand(ckPass, conn);
string password = PassComm.ExecuteScalar().ToString().Replace(" ", "");
conn.Close();
if (password == LoginPassTB.Text)
{
Session["Login"] = LoginTB.Text;
Response.Redirect("Account.aspx");
}
else
{
LoginLbl.Text = "CFA Name or Password is incorrect";
}
}
else
{
LoginLbl.Text = "CFA Name does not exist";
}
}
}
}
你有一個SQL注入漏洞。 – SLaks 2014-10-07 02:57:11
** **如何不起作用?它爆炸了嗎? – SLaks 2014-10-07 02:57:34
當我以登錄表格 – 2014-10-07 03:01:11