After filling in the registration submission, the larger site will have the mailbox activation verification This step, this article is also realized a bit, interested friends can refer to ha, hope can help you-----------registration page front Desk
Copy CodeThe code is as follows:
<%@ page language= "C #" autoeventwireup= "true" codebehind= "Registe.aspx.cs" inherits= "csdn blog. Registe"%>
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<title></title>
<style type= "Text/css" >
. Zhuyi
{
color:red;
Font-size:small;
}
#pwd-strong {
Float:left;
margin:0px;
padding:0px;
List-style:none;
Background-image:url (images/pwdstrong.gif);
Background-repeat:no-repeat;
}
#pwd-strong Li {
Float:left;
padding:0px;
Color: #ccc;
font-size:11px;
width:64px;
height:10px;
Text-align:center;
padding-top:9px;
}
. pwds3 {
Background-position: -20px-70px;
}
. pwds2 {
Background-position: -20px-44px;
}
. pwds1 {
Background-position: -20px-18px;
}
#pwd-strong Li.currs {
Color: #000;
}
/* Header CSS style */
#head
{
margin:0;
}
#head a:hover
{
color:red;
}
. Ahead
{
Color:black;
Font-size:small;
Text-decoration:none;
}
#lefthead
{
Float:left;
margin:0;
}
#righthead
{
Float:right;
margin:0;
}
/* End CSS style ends */
/* Information Section Start */
#body
{
/*
BORDER:1PX solid black;
*/
Position:absolute;
width:900px;
height:700px;
left:230px;
top:50px;
}
#picture
{
Float:left;
}
#xinxi
{
BORDER:1PX solid Pink;
width:850px;
height:440px;
Position:absolute;
left:20px;
top:50px
}
#biaoti
{
Position:absolute;
left:1px;
top:10px;
}
#xian
{
Position:absolute;
left:20px;
top:50px;
}
#table
{
Position:absolute;
/*
BORDER:1PX solid black;
*/
left:50px;
top:90px;
}
/* End of Information section */
/* Bottom Start */
#footer
{
/*
BORDER:1PX solid black;
*/
Position:absolute;
left:430px;
top:560px;
}
. buttom
{
margin:0px;
Font-size:small;
}
. abuttom
{
Text-decoration:none;
Color:black;
}
#footer a:hover
{
Color:blue;
}
Img
{
border:0px;
}
/* Bottom End */
</style>
<script src= "Emailvalidatorjs.js" type= "Text/javascript" ></script>
<script src= "Jquery-1.9.1.js" type= "Text/javascript" ></script>
<script type= "Text/javascript" >
$ (function () {
$ (' #txtPassword '). KeyUp (function () {
var score = Testpass ($ (this). Val ());
If (Score < 34) {
$ (' #pwd-strong '). CSS (' Display ', ' block ');
$ (' #pwd-strong '). addclass (' pwds1 ');
$ (' Li:first '). addclass (' Currs ');
}
else if (score >= && Score < 68) {
$ (' #pwd-strong '). CSS (' Display ', ' block ');
$ (' #pwd-strong '). Removeclass ();
$ (' #pwd-strong '). addclass (' pwds2 ');
$ (' Li:eq (1) '). addclass (' Currs ');
}
else {
$ (' #pwd-strong '). CSS (' Display ', ' block ');
$ (' #pwd-strong '). Removeclass ();
$ (' #pwd-strong '). addclass (' Pwds3 ');
$ (' Li:last '). addclass (' Currs ');
}
})
})
</script>
<body>
<form id= "Form1" runat= "Server" >
<!--Content--
<div>
<!--head--
<div id= "Head" >
<!--head Left-to
<div id= "Lefthead" >
<a href= "http://www.csdn.net/" class= "ahead" > Home </a>
<a href= "http://news.csdn.net/" class= "ahead" > Industry </a>
<a href= "http://mobile.csdn.net/" class= "ahead" > Mobile </a>
<a href= "http://cloud.csdn.net/" class= "ahead" > Cloud computing </a>
<a href= "http://sd.csdn.net/" class= "ahead" > r </a> D
<a href= "http://bbs.csdn.net/" class= "ahead" > Forum </a>
<a href= "http://blog.csdn.net/" class= "ahead" > Blogs </a>
<a href= "http://download.csdn.net/" class= "ahead" > Downloads </a>
<a class= "Ahead" > more </a>
</div>
<!--head Right--
<div id= "Righthead" >
<span class= "Zhuyi" > You haven't landed yet! </span>|
<a href= "http://www.csdn.net/" class= "ahead" > Login </a> |
<a href= "http://www.csdn.net/" class= "ahead" > Registration </a> |
<a href= "Https://passport.csdn.net/help/faq" class= "ahead" > Help </a>
</div>
</div>
<!--head End--
<!--body--
<div id= "Body" >
<!--Pictures--
<div id= "Picture" >
</div>
<!--information--
<div id= "Xinxi" >
<div id= "Biaoti" >
</div>
<div id= "Xian" >
</div>
<div id= "Table" >
<table>
<!--user name--
<tr>
<td><span class= "Zhuyi" >*</span> user name:</td>
<td>
<asp:textbox id= "txtname" runat= "Server" controltovalidate= "TextBox1" ></asp:TextBox></td>
<TD >
<asp:requiredfieldvalidator id= "RequiredFieldValidator1" runat= "Server"
Errormessage= "User name cannot be empty" controltovalidate= "txtname" display= "Dynamic"
Font-size= "15px" forecolor= "Red" ></asp:RequiredFieldValidator>
</td>
</tr>
<TR><TD></TD><TD colspan= "2" >
<label style= "color: #c0c0c0; font-size:small;" > (a combination of letters, numbers, or underscores.) ) </label></td></tr>
<!--password--
<tr>
<td><span class= "Zhuyi" >*</span> password:</td>
<td>
<asp:textbox id= "Txtpassword" runat= "Server" ></asp:TextBox></td>
<td>
<asp:requiredfieldvalidator id= "RequiredFieldValidator2" runat= "Server"
Controltovalidate= "Txtpassword" display= "Dynamic" errormessage= "cannot be empty"
Font-size= "15px" forecolor= "Red" ></asp:RequiredFieldValidator>
<div><ul id= "Pwd-strong" style= "Display:none;" ><li> Weak </li><li> medium </li><li> strong </li></ul></div></td>
</tr>
<TR><TD></TD><TD colspan= "2" >
<label style= "color: #c0c0c0; font-size:small;" > (For your account security, it is strongly recommended that your password use a combination of characters + numbers and many different types, and that the password length is greater than 5 bits.) ) </label></td></tr>
<!--re-enter the password--
<tr>
<td><span class= "Zhuyi" >*</span> re-enter password:</td>
<td>
<asp:textbox id= "Txtpasswordagain" runat= "Server" ></asp:TextBox></td>
<td>
<asp:requiredfieldvalidator id= "RequiredFieldValidator3" runat= "Server"
Controltovalidate= "Txtpassword" display= "Dynamic" errormessage= "cannot be empty"
Forecolor= "Red" font-size= "15px" ></asp:RequiredFieldValidator>
<asp:comparevalidator id= "CompareValidator1" runat= "Server"
Errormessage= "two times input password inconsistent" controltocompare= "Txtpassword"
Controltovalidate= "Txtpasswordagain" display= "Dynamic" forecolor= "Red"
Font-size= "15px" ></asp:CompareValidator></td>
</tr>
<TR><TD></TD><TD colspan= "2" >
<label style= "color: #c0c0c0; font-size:small;" > (Make sure your password is correct) </label></td></tr>
<!--e-mail-->
<tr>
<td><span class= "Zhuyi" >*</span>E-mail</td>
<td>
<asp:textbox id= "Txtemail" runat= "Server" ></asp:TextBox></td>
<td>
<asp:requiredfieldvalidator id= "RequiredFieldValidator4" runat= "Server"
Controltovalidate= "Txtemail" display= "Dynamic" errormessage= "cannot be empty"
Forecolor= "Red" font-size= "15px" ></asp:RequiredFieldValidator>
<asp:regularexpressionvalidator id= "RegularExpressionValidator1" runat= "Server"
Controltovalidate= "Txtemail" display= "Dynamic" errormessage= "Mailbox format is incorrect"
Validationexpression= "\w+ ([-+.] \w+) *@\w+ ([-.] \w+) *\.\w+ ([-.] \w+) * "
Forecolor= "Red" font-size= "15px" ></asp:RegularExpressionValidator>
</td>
</tr>
<TR><TD></TD><TD colspan= "2" >
<label style= "color: #c0c0c0; font-size:small;" > (please fill in your usual email) </label></td></tr>
<!--verification code--
<tr>
<td><span class= "Zhuyi" >*</span> check code:</td>
<td>
<asp:textbox id= "TEXTBOX5" runat= "Server" ></asp:TextBox></td>
<td>
picture unclear? Click to re-get verification code
<asp:requiredfieldvalidator id= "RequiredFieldValidator5" runat= "Server"
Controltovalidate= "TextBox5" display= "Dynamic" errormessage= "cannot be empty" ></asp:RequiredFieldValidator>
</td>
</tr>
<TR><TD></TD><TD colspan= "2" >
<span class= "Zhuyi" > (If you do not enter the verification code consecutively, please check if your browser has disabled cookies.) <a href= "Http://passport.csdn.net/help/faq" > How do I enable cookies? </a>) </span></td></tr>
<tr>
<!--terms--
<td><span class= "Zhuyi" >*</span> Terms of incorporation:</td>
<TD colspan= "2" >
<asp:checkbox id= "CheckBox1" runat= "Server"
Oncheckedchanged= "checkbox1_checkedchanged" text= "I have carefully read and accept the/><a href=" http://passport.csdn.net/help/terms ">CSDN Registration terms </a>. </td>
</tr>
<!--sign up and submit
<tr><td></td><td></td></tr>
<tr><td></td><td></td></tr>
<tr>
<td></td>
<TD colspan= "2" >
<asp:imagebutton id= "ImageButton1" runat= "Server"
Imageurl= "~/images/zhuce.jpg" onclick= "Imagebutton1_click"/>
<asp:label id= "Lbinfo" runat= "Server" forecolor= "Red" ></asp:Label>
</td>
</tr>
</table>
<div>
</div>
</div>
</div>
</div>
<!--body End--
<!--Bottom--
<div id= "footer" align= "Center" >
<div class= "Buttom" >
<a href= "http://www.csdn.net/company/about.html" class= "Abuttom" > Company Profile </a>|
<a href= "http://www.csdn.net/company/recruit.html" class= "Abuttom" > Careers </a>|
<a href= "http://www.csdn.net/company/marketing.html" class= "Abuttom" > Advertising Services </a>|
<a href= "http://www.csdn.net/company/account.html" class= "Abuttom" > Bank Transfer Account </a>|
<a href= "http://www.csdn.net/company/contact.html" class= "Abuttom" > Contact Us </a>|
<a href= "http://www.csdn.net/company/statement.html" class= "abuttom" > Copyright Notice </a>|
<a href= "http://www.csdn.net/company/layer.html" class= "Abuttom" > Legal Counsel </a>|
<a href= "" class= "Abuttom" > Problem report </a>
</div>
<p class= "Buttom" > Beijing ICP Certificate No. No. 070598 </p>
<p class= "Buttom" > Beijing Innovation Music Information Technology Co., Ltd. All rights reserved </p>
<p class= "Buttom" > Contact Email: webmaster (at) csdn.net</p>
<p class= "Buttom" >copyright? 1999-2012, csdn.net, All rights reserved</p>
<div>
<a href= "http://www.hd315.gov.cn/beian/view.asp?bianhao=010202001032100010" class= "Abuttom" ></a>
<a href= "https://trustsealinfo.verisign.com/splash?form_file=fdf/splash.fdf&dn=passport.csdn.net& LANG=ZH_CN "class=" Abuttom "></a>
</div>
------Registration Page Background
Copy CodeThe code is as follows:
Using System;
Using System.Collections.Generic;
Using System.Linq;
Using System.Web;
Using System.Web.UI;
Using System.Web.UI.WebControls;
Using System.Text;
Using System.Net.Mail;
Using System.Net;
Using System.Data.SqlClient;
Namespace CSDN Blog
{
public partial class Registe:System.Web.UI.Page
{
protected void Page_Load (object sender, EventArgs e)
{
}
protected void Checkbox1_checkedchanged (object sender, EventArgs e)
{
}
public void SendMail (string email, string activecode)
{
MailMessage MAILMSG = new MailMessage ();
Mailmsg.from = new MailAddress ("[email protected]");
MAILMSG.TO.ADD (email);
Mailmsg.subject = "Please activate registration";
int number = Number1 ();
StringBuilder Contentbuilder = new StringBuilder ();
Contentbuilder.append ("Please click on the link below to complete activation");
Contentbuilder.append ("<a href= ' http://localhost:15464/cheng.aspx?activecode=" + Activecode + "&id=" + number + "' > Activation </a>");
Mailmsg.body = Contentbuilder.tostring ();//splicing string
Mailmsg.isbodyhtml = true;
SmtpClient client = new SmtpClient ();
Sender-Side server address
Client. Host = "smtp.163.com";
Client. Port = 25;
Mailmsg.isbodyhtml = true;
NetworkCredential credetial = new NetworkCredential ();
Credetial. UserName = "15031259715";
Credetial. Password = "wangjing911214++";
Client. Credentials = credetial;
Client. Send (MAILMSG);
}
public int Number1 ()
{
CSDN blog. Bll.t_user count = new BLL. T_user ();
int a = count. GetRecordCount ("");
return A;
}
protected void Imagebutton1_click (object sender, ImageClickEventArgs e)
{
CSDN blog. Model.t_user muser = new Model.t_user ();
Muser. Name = txtName.Text;
Muser. Password = txtPassword.Text;
Muser. E_Mail = Txtemail.text;
String Activecode=guid.newguid (). ToString (). Substring (0, 8);
Muser. Activecode = activecode;//Generate Activation code
CSDN blog. Bll.t_user buser = new BLL. T_user ();
if (buser. ADD (Muser) > 0)
{
SendMail (Txtemail.text, Activecode);//Send mail to registered users
Lbinfo. Text = "Saved successfully";
}
else {lbinfo. Text = "Save Failed"; }
}
}
}
</div>
<!--bottom End--
</div>
</form>
</body>
------------Activation Verification
Copy CodeThe code is as follows:
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;
Namespace CSDN Blog
{
public partial class Cheng:System.Web.UI.Page
{
protected void Page_Load (object sender, EventArgs e)
{
Remove parameter ID
int id = Convert.ToInt32 (request["id"]);
String activecode = request["Activecode"]. ToString ();
2 Determine whether a record with ID ID is present
Connecting to a database
String constr = "Data source=love-pc\\sqlexpresspc;initial catalog=blogs;user id=sa;password=admin";
int number;
using (SqlConnection con = new SqlConnection (CONSTR))
{
String sql = "SELECT COUNT (*) from t_user where [email protected]";
using (SqlCommand cmd = new SqlCommand (sql, con))
{
Con. Open ();
Cmd. Parameters.addwithvalue ("@id", id);
Number = Convert.ToInt32 (cmd). ExecuteScalar ());
}
}
if (number > 0)
{
If the user exists, remove the Activecode field for comparison. If same, modify the active field to True
Connecting to a database
String AC;
using (SqlConnection con = new SqlConnection (CONSTR))
{
String sql = "Select Activecode from T_user where [email protected]";
using (SqlCommand cmd = new SqlCommand (sql, con))
{
Con. Open ();
Cmd. Parameters.addwithvalue ("@id", id);
AC = cmd. ExecuteScalar (). ToString ();;
}
}
if (Activecode = = AC)
{
Response.Write ("Activation succeeded!<a href= ' denglu.aspx ' > Return login </a>");
using (SqlConnection con = new SqlConnection (CONSTR))
{
String sql = "Update t_user set active=1 where [email protected]";
using (SqlCommand cmd = new SqlCommand (sql, con))
{
Con. Open ();
Cmd. Parameters.addwithvalue ("@id", id);
Number = Convert.ToInt32 (cmd). ExecuteScalar ());
}
}
}
Else
{
Response.Write ("The user already exists, but the activation code is wrong!") ");
}
}
Else
{
Response.Write ("User does not exist, has not registered successfully!") ");
}
}
}
}
Achieve the following effects:
If you have questions about this article, please submit to the Exchange community, the vast number of enthusiastic netizens will answer for you!! Click to enter the community
Articles you may be interested in:
- ASP generation and Refresh and validation
- ASP. NET MVC authentication, exception handling, permission validation (interceptor) Implementation code
- ASP Implementation Code (C #)
- ASP (C #) generates code for random verification codes
- Asp. NET form validation methods
- JQuery authentication Plug-in web front-end design mode (ASP)
- ASP. NET (C #) Implementation code for CAPTCHA function
- Introduction to ASP. NET authentication method
- ASP. NET Simple Verification Code verification Implementation Code
- Remote Validation for the ASP. NET MVC5 Verification series
The registration page implements the detailed implementation of activation mailbox validation (ASP. NET C #)