| 网站首页 | 文章中心 | 下载中心 | 编程世界论坛 | 图片中心 | 留言板 | 发布源码 | 
您现在的位置: 编程世界 >> 文章中心 >> ASP文章 >> 文章正文 用户登录 新用户注册
ASP实现生成随机密码并发送到注册会员的邮箱         ★★★ 【字体:
ASP实现生成随机密码并发送到注册会员的邮箱
作者:佚名    文章来源:本站原创    点击数:    更新时间:2008-3-12    

此文实现自动生成随机密码,并自动将此密码发送到注册会员的邮箱。

这里使用的是微软自带的cdonts组件来发送邮件的,如果你想用Jmail组件只改改下面指定的部分就行了。

<%@language="vbscript" %> 

****************************** 
<% 
’code by www.ibiancheng.cn 
’Web Developer 
’3rd Agenda 
’Sanmao china
%> 

<% 

set mail= server.CreateObject("cdonts.newmail")            '这里使用的是微软自带的cdonts组件来发送邮件的,如果你想用Jmail组件只改改这个地方就行了
mail.subject="Thank You for Registering" 
mail.to = mailid mail.from ="Webmaster@thesite"            '填写源邮箱地址
mail.body= "This is the Initial Password to our site...." & vbcrlf 
&href=’mailto:mailid="user@ursite.com’>mailid="user@ursite.com
address="address" 


’other data like phone number as per the member database in the site 
’all these values are obtained from the request method from a .htm which submits to this file 
’Mainly employed in registration 
’Assumes You have cdonts.dll installed in the web server. 

set conn = server.CreateObject("adodb.connection") 
conn.Open "dsn","uid","pwd" 
set rec= conn.Execute("select count(*) from membertable") 
id = cint(rec.fields(0))+1 
r=rnd *50 
Response.Write r & "<br>" 
for i = 0 to 20 
if cint(r)>0 and cint(r)<26 then str=str +chr(97 + cint(r)) 
r=rnd *100 
next 

Response.Write str 
pwd=left(str,2) 
pwd=pwd & id 
pwd=pwd & right(str,2) 
pwd=pwd & second(time) 

’An Update Query can be Passed from here for the username ,password and other details or can be triggered 
from another page ’when the user responds to the mail...Something like sending a url as a mail and on 
click of the url in the mail..call another page ’which updates ..so we can be sure that only confirmed 
users are updated 

%> 
<br> 
<% 
set mail= server.CreateObject("cdonts.newmail") 
mail.subject="Thank You for Registering" 
mail.to = mailid 
mail.from ="Webmaster@thesite
mail.body= "This is the Initial Password to our site...." & vbcrlf & "Change it if You Want" & vbcrlf & 
pwd & vbcrlf & "Thank You for Using the Site" 
mail.send 
%>

ok
这样就完成了,不推荐大家照搬使用,推荐你慢慢看,细细吃透然后自己编写。

文章录入:admin    责任编辑:admin 
  • 上一篇文章:

  • 下一篇文章: 没有了
  • 发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
    最新热点 最新推荐 相关文章
    ASP高效率实现分页代码
    filesystemobject(简称fso)对
    asp+vbscript判断客户端是否
    asp server对象详细用法
    ASP网站实现防止被采集
    保护asp源代码,即使有服务器
      网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)