If you have questions or suggestions when reading, please point out and ask questions, I am also a beginner ...
Front Code:
<! DOCTYPE html>"http://www.w3.org/1999/xhtml"> "Server"> <title></title> "Center"> "Form1"runat="Server"> <p> <asp:label id="Lbusername"runat="Server"> No.:</asp:label> <asp:textbox id="Txtnum"runat="Server"></asp:TextBox> </p> <p> <asp:label id="Lblname"runat="Server"> Name:</asp:label> <asp:textbox id="txtname"runat="Server"></asp:TextBox> </p> <p> <asp:label id="LBPSW"runat="Server"> Password:</asp:label> <asp:textbox id="txtpwd"runat="Server"Textmode="Password"></asp:TextBox> </p> <p> <asp:label id="Lbltext"runat="Server"text=""></asp:Label></p> <p> <asp:button id="Btnregister"runat="Server"text="Register"onclick="Btnregister_click"/> </p> </form> </div> </body> Background code:
usingSystem;usingSystem.Data.SqlClient;usingSystem.Data;usingSystem.Configuration;usingSystem.Drawing;usingSystem.Text;usingSystem.Security.Cryptography;namespaceado.netdemo1{ Public Partial classregister:System.Web.UI.Page {SqlConnection connstr=NewSqlConnection (configurationmanager.connectionstrings["ConnStr"]. ToString ()); stringSQL; protected voidPage_Load (Objectsender, EventArgs e) { } protected voidBtnregister_click (Objectsender, EventArgs e) { if(TxtNum.Text.Trim () = =""|| TxtName.Text.Trim () = =""|| Txtpwd. Text.trim () = ="") {Lbltext.forecolor=color.red; Lbltext.text="please complete the personal information! "; } Else if(TxtNum.Text.Trim () = =""&& TxtName.Text.Trim () = =""&& txtpwd. Text.trim () = ="") {Lbltext.forecolor=color.red; Lbltext.text="please complete the personal information! "; } Else { //Cryptographic processing Registration Password stringHashedpwd=Encrypt (txtpwd. Text.trim ()); SQL="INSERT INTO tb_students (Sid,name,password) Values ('"+ TxtNum.Text.Trim () +"', '"+ TxtName.Text.Trim () +"', '"+ Hashedpwd +"')"; Connstr.open (); SqlCommand cmd=NewSqlCommand (SQL, CONNSTR); inti =cmd. ExecuteNonQuery (); if(i = =1) {Lbltext.forecolor=color.red; Lbltext.text="Registration Successful! "; Response.Write (@"<script>window.alert (' Please login to login screen! '); window.location= ' Login.aspx ' </script>"); } } } Public Static stringEncrypt (stringcleanstring) {byte[] clearbytes=Newunicodeencoding (). GetBytes (cleanstring); Byte[] Hashedbytes= ((HashAlgorithm) Cryptoconfig.createfromname ("MD5")). ComputeHash (clearbytes); returnbitconverter.tostring (hashedbytes); } }}Interface:
"ADO. NET Foundation-regidter "Simple account Registration interface and source code (can be used for simple interview basic Learning)