Using system;
Using system. Data;
Using system. configuration;
Using system. collections;
Using system. Web;
Using system. Web. Security;
Using system. Web. UI;
Using system. Web. UI. webcontrols;
Using system. Web. UI. webcontrols. webparts;
Using system. Web. UI. htmlcontrols;
Using system. Data. sqlclient;
Public partial class usecontrols_header: system. Web. UI. usercontrol
{
Protected void page_load (Object sender, eventargs E)
{
If (! Ispostback)
{
// Generate a random number (4 digits) and display it as a verification code during initialization.
Random YZM = new random ();
This. labvali. Text = YZM. Next (1000,999 9). tostring ();
}
}
Protected void btnreg_click (Object sender, eventargs E)
{
Page. response. Redirect ("~ /Module/blog/regpro. aspx ");
}
Protected void btnok_click (Object sender, eventargs E)
{
If (this.txt vali. Text! = This. labvali. Text)
{
Response. Write ("<SCRIPT Lanuage = JavaScript> alert ('verification code error'); location = 'javascript: history. Go (-1) '</SCRIPT> ");
}
Else
{
Sqlconnection con = new sqlconnection (configurationmanager. etettings ["constr"]);
Con. open ();
Sqlcommand COM = new sqlcommand ("select count (*) from tb_blog where username = '" + this.txt uid. text + "'and Password ='" + this.txt PWD. text + "'", con );
Int COUNT = convert. toint32 (COM. executescalar ());
If (count> 0)
{
Session ["username"] = this.txt uid. text;
Session ["password"] = this.txt PWD. text;
Page. response. Redirect ("module/blog/index. aspx ");
}
Else
{
Response. Write ("<SCRIPT Lanuage = JavaScript> alert ('user name or password is incorrect! '); Location = 'javascript: history. Go (-1)' </SCRIPT> ");
Return;
}
}
}
}