[英]Programmatically login to a website and redirect the user to the logged in page?
[英]Navigation from the login page after the user logged in
這是我登錄頁面的代碼。 但用戶登錄后沒有“導航”編碼。需要一些幫助對此進行編碼。(導航代碼導航至下一個表單)
namespace WindowsFormsApplication2
{
public partial class Form5 : Form
{
public Form5()
{
InitializeComponent();
}
private void Form5_Load(object sender, EventArgs e)
{
using(SqlConnection myconnection = new SqlConnection("Data Source=chariths-bently\\charith;Initial Catalog=emp_mgt;Integrated Security=True"))
{
}
}
private void login_Click(object sender, EventArgs e)
{
if (ok(username.Text, password.Text) > 0)
MessageBox.Show("Access granted");
else
MessageBox.Show("access denied");
}
private int ok( string username, string password)
{
username.Trim();
password.Trim();
SqlDataReader dr = null;
using(SqlConnection myconnection = new SqlConnection("Data Source=chariths-bently\\charith;Initial Catalog=emp_mgt;Integrated Security=True"))
{
myconnection.Open();
string query = "select * from emp_info ";
SqlCommand cmd = new SqlCommand(query,myconnection);
if(cmd.ExecuteScalar () != null)
return 1;
else
return 0;
}
}
}
}
private void login_Click(object sender, EventArgs e)
{
if (ok(username.Text, password.Text) > 0)
{
MessageBox.Show("Access granted");
Form6 f6 = new Form6(); // create your next form instance,(form6, for example)
f6.Open();
this.Close();
}
....
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.