<! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<HTML xmlns = "http://www.w3.org/1999/xhtml">
<Head id = "head1" runat = "server">
<Title> password retrieval for individual Members </title>
<Link href = "/style.css" rel = "stylesheet" type = "text/CSS"/>
<Script language = "JavaScript" type = "text/JavaScript">
// Check whether email has been registered
Function checkemail ()
{
VaR E = Document. getelementbyid ("email"). value;
If (E! = "")
{
If (! /(\ S) + [@] {1} (\ s) + [.] {1} (\ W) +/. Test (e ))
{
Alert ("enter an email address in the correct format! ");
VaR email = Document. getelementbyid ("email ");
Email. value = "";
Email. Focus ();
}
}
}
Function checkall ()
{
VaR EE = Document. getelementbyid ("username"). value;
If (EE = "")
{
Alert ('logon name cannot be blank ');
Return false;
}
VaR E = Document. getelementbyid ("email"). value;
If (E = "")
{
Alert ('emial cannot be blank ');
Return false;
}
}
</SCRIPT>
</Head>
<Body>
<Form ID = "form1" runat = "server">
<Div>
<Table width = "778" border = "0" align = "center" cellpadding = "5" cellspacing = "0" class = "table_huang">
<Tr>
<TD colspan = "2" class = "td_huang_14_write"> <span style = "font-size: 11pt" >>> get password </span> </TD>
</Tr>
<Tr>
<TD width = "26"> </TD>
<TD width = "724"> <Table width = "90%" border = "0" cellspacing = "2" cellpadding = "5">
<Tr>
<TD width = "23%"> <Div align = "right"> User name: </div> </TD>
& Lt; TD width = "77%" & gt;
<Asp: textbox id = "username" runat = "server" width = "150px"> </ASP: textbox> </TD>
</Tr>
<Tr>
<TD> <Div align = "right"> email entered at registration: </div> </TD>
<TD>
<Asp: textbox id = "email" runat = "server" width = "200px"> </ASP: textbox> </TD>
</Tr>
<Tr>
<TD> <Div align = "right"> Verification Code: </div> </TD>
& Lt; TD & gt; & lt; table width = "100%" & gt;
<Tr>
<TD align = "Left" valign = "TOP" style = "width: 64px"> <asp: textbox id = "txt_validcode" runat = "server" Height = "15px" width = "62px"> </ASP: textbox> </TD>
<TD align = "Left" valign = "TOP"> </TD>
</Tr>
</Table> </TD>
</Tr>
<Tr>
<TD colspan = "2" style = "text-align: Center">
<Asp: button id = "button1" runat = "server" text = "retrieve password"/> </TD>
</Tr>
</Table> </TD>
</Tr>
</Table>
</Div>
</Form>
</Body>
</Html>
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;
Public partial class clientserver_default2: system. Web. UI. Page
{
String lspass = "";
Protected void page_load (Object sender, eventargs E)
{
If (! Ispostback)
{
This. button1.attributes. Add ("onclick", "javascript: Return checkall ();");
}
}
Protected void button#click (Object sender, eventargs E)
{
Httpcookie mycookie_validcode = request. Cookies ["fwcx_checkcode"];
If (mycookie_validcode.value.tostring ()! = Txt_validcode.text)
{
Response. Write ("<SCRIPT> ");
Response. Write ("alert ('verification code error ')");
Response. Write ("</SCRIPT> ");
Return;
}
// First, determine whether the logon name and email exist.
String SQL = "select * From t_users where u_username = '" + username. text. trim () + "'and u_email ='" + email. text. trim () + "'and u_class = '0' and u_valid = '1 '";
Datatable dt = new datatable ();
// DT = new sqltool (). datatable (SQL );
If (Dt. Rows. Count <1)
{
Response. Write ("<SCRIPT> alert ('logon name or email address is incorrect !, Please fill in again and try again. '); </SCRIPT> ");
}< br> else
{< br> // attach a temporary password to the current database t_users
// response. write (createrandomcode (8);
lspass = createrandomcode (8 );
SQL = "Update t_users set u_getpwd = '" + lspass + "'where u_username ='" + username. text. trim () + "'and u_email ='" + email. text. trim () + "'and u_class = '0' and u_valid = '1'";
// If (New sqltool (). executesql (SQL)> = 0)
// {
sendemail (email. text. trim (), username. text. tri M ();
response. Write (" ");
//}
}< BR >}< br> Public void sendemail (string email, string name)
{< br> try
{< br> jmail. message jmessage = new jmail. message ();
jmessage. charset = "gb2312";
jmessage. from = "86085005@163.com";
// mail address
jmessage. mailserverusername = "86085005";
// SMTP authentication username (NOTE: For Netease users, @ 163.comis not added, as long as the previous part is required)
jmessage. mailserverpassword = "kingseer";
// SMTP argument username and password
Jmessage. fromname = "108 human bank ";
// Sender
Jmessage. replyto = "86085005@163.com ";
// Reply address
Jmessage. C; // The email content is html
Jmessage. Subject = "108 temporary password of human bank ";
String strbody = "";
Strbody + = new functions (). getinfoxx ("t_pagetexts", "p_name", "retrieve password email feedback-personal", "p_value "). replace ("$", name ). replace ("@ %", lspass );
Jmessage. htmlbody = strbody;
// Mail title
Jmessage. addrecipient (email ,"","");
Jmessage. Send ("smtp.163.com", false); // send smtp.163.com
Jmessage. Close (); // close the object and release the resource.
}
Catch (exception ERR)
{
Response. Write (ERR );
}
}
/// <Summary>
/// Function: generate a random string mixed with numbers and characters
/// </Summary>
/// <Param name = "codecount"> Number of strings </param>
/// <Returns> </returns>
Private string createrandomcode (INT codecount)
{
// Mixed string of numbers and characters
String allchar = ", A, B, C, D, E, F, G, H, I, J, K, L, M, N ";
// Split into Arrays
String [] allchararray = allchar. Split (',');
String randomcode = "";
// Random number instance
System. Random Rand = new system. Random (unchecked (INT) datetime. Now. ticks ));
For (INT I = 0; I <codecount; I ++)
{
// Obtain a random number
Int T = Rand. Next (allchararray. Length );
// Synthesize a random string
Randomcode + = allchararray [T];
}
Return randomcode;
}
}