仓酷云

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 3254|回复: 20
打印 上一主题 下一主题

[学习教程] ASP网页编程之创立一个告白互换及跟踪体系

[复制链接]
活着的死人 该用户已被删除
跳转到指定楼层
楼主
发表于 2015-2-3 23:32:21 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
缺点:安全性不是太差了,还行,只要你充分利用系统自带的工具;唯一缺点就是执行效率慢,如何进行网站优化以后,效果会比较好。   First you need a database to store your banners. We are using 2 tables; tblBanners and tblVendors:

tblBanners:
bID - auto number (banner ID)
bBanner - text (image file)
bUsedViews - number (# of views the banner has received)
bTotalViews - number (# of impressions the vendor has paid for)
bClicks - number (# of clicks the banner has received)
bURL - text (URL of the site)
bShow - yes/no (used to show and hide banners)
vID - number (vendor ID)

tblVendors:
vID - autonumber (vendor ID - links to tblBanners.vID)
vName - text (Vendor's name)
etc..........


Now that the database is set up, we need to randomly display the banner on our pages and increment the 'views' by 1:

First you need to open your database connection on the page you want your banner to be viewed on. We use a DSN-less connection; you can find it at the following address:

http://www.askasp.com/toolbox.asp?Expand=True&ID=2#tool

Here is what the SQL might look like:

SQL = "SELECT tblBanners.bID, tblBanners.bImage, tblBanners.bUsedViews, tblBanners.bLastViewed "
SQL = SQL & "FROM tblBanners "
SQL = SQL & "WHERE (((tblBanners.bShow)=True) AND ((tblBanners.bTotalViews)>[tblBanners].[bUsedViews]));"

In the above SQL, we are checking for the 'bShow' flag to be True, and that the UsedViews is less than the TotalViews.

Now that we have all of the banners that we can display, we need to display a random one. We can do this by grabbing the total number of banners, moving to the first record, and the moving to a random number, for example:


Dim rndMax, rndNumber

Randomize

rndMax = Int(RecordSet.RecordCount)
rndNumber = Int(RND * rndMax)

RecordSet.Move rndNumber


Now that we have moved to our random banner, we now need to display the banner on our page (I am sure you know how to do that, so I wont bore you with the details). However, Instead of using the banner's URL in the link, we are going to use a redirect page so we can count the clicks. All we need to do is use the banner ID in the HREF tag, for example:

a href="redirect.asp?ID=<%= BANNER ID %>"

Now that we have the link set up, we can move on to our redirect.asp page. On this page, we are going to grab the ID that we are passing in the Query String, and grabbing the RecordSet that matches. Once we have the RecordSet, we can grab the banner's URL, increase the Clicks by 1, and send the user to the destination URL. Below is the code for the redirect.asp page:

<%
If Request.QueryString("ID") = "" Then
Response.Redirect("default.asp")
End If

Dim varSiteToRedirect, varURLToRedirect

varSiteToRedirect = Int(Request.QueryString("ID"))


SQL = "SELECT tblBanners.bID, tblBanners.bURL, tblBanners.bClicks "
SQL = SQL & "FROM tblBanners "
SQL = SQL & "WHERE (((tblBanners.bID)=" & varSiteToRedirect & "));"

varDatabaseName = "ask_asp_data.mdb"
%>

<!--#include file="common/data_conn_open.asp"-->

<%
If Not RecordSet.BOF Then
RecordSet.MoveFirst
End If

varURLToRedirect = RecordSet.Fields("bURL")

RecordSet.Fields("bClicks") = (RecordSet.Fields("bClicks") + 1)
RecordSet.Update
%>

<!--#include file="common/data_conn_close.asp"-->

<% Response.Redirect(varURLToRedirect) %>
SQL Server是基于服务器端的中型的数据库,可以适合大容量数据的应用,在功能上管理上也要比Access要强得多。在处理海量数据的效率,后台开发的灵活性,可扩展性等方面强大。
飘飘悠悠 该用户已被删除
沙发
发表于 2015-2-4 01:42:24 | 只看该作者
Application:这个存储服务端的数据,如果不清除,会直到web应用程序结束才清除(例如重启站点)
谁可相欹 该用户已被删除
板凳
发表于 2015-2-4 01:42:24 | 只看该作者
在平时的学习过程中要注意现学现用,注重运用,在掌握了一定的基础知识后,我们可以尝试做一些网页,也许在开始的时候我们可能会遇到很多问题,比如说如何很好的构建基本框架。
透明 该用户已被删除
地板
发表于 2015-2-7 09:55:20 | 只看该作者
不能只是将它停留在纸上谈兵的程度上。
愤怒的大鸟 该用户已被删除
5#
发表于 2015-2-8 05:23:38 | 只看该作者
跟学别的语言一样,先掌握变量,流程控制语句(就是ifwhileselect)等,函数/过程,数组
活着的死人 该用户已被删除
6#
 楼主| 发表于 2015-2-12 06:51:36 | 只看该作者
掌握asp的特性而且一定要知道为什么。
因胸联盟 该用户已被删除
7#
发表于 2015-2-15 22:10:11 | 只看该作者
Response:从字面上讲是“响应”,因此这个是服务端向客户端发送东西的,例如Response.Write
小妖女 该用户已被删除
8#
发表于 2015-2-19 19:02:36 | 只看该作者
完全不知道到底自己学的是什么。最后,除了教程里面说的几个例子,还是什么都不会。
柔情似水 该用户已被删除
9#
发表于 2015-2-20 23:51:16 | 只看该作者
ASP.Net摆脱了以前ASP使用脚本语言来编程的缺点,理论上可以使用任何编程语言包括C++,VB,JS等等,当然,最合适的编程语言还是MS为.NetFrmaework专门推出的C(读csharp),它可以看作是VC和Java的混合体吧。
小魔女 该用户已被删除
10#
发表于 2015-3-6 19:05:14 | 只看该作者
我就感觉到ASP和一些常用的数据库编程以及软件工程方面的思想是非常重要的。我现在也在尝试自己做网页,这其中就用到了ASP,我想它的作用是可想而知的。
老尸 该用户已被删除
11#
发表于 2015-3-13 06:09:24 | 只看该作者
Request:从字面上讲就是“请求”,因此这个是处理客户端提交的东东的,例如Resuest.Form,Request.QueryString,或者干脆Request("变量名")
变相怪杰 该用户已被删除
12#
发表于 2015-3-20 14:28:18 | 只看该作者
运用ASP可将VBscript、javascript等脚本语言嵌入到HTML中,便可快速完成网站的应用程序,无需编译,可在服务器端直接执行。容易编写,使用普通的文本编辑器编写,如记事本就可以完成。由脚本在服务器上而不是客户端运行,ASP所使用的脚本语言都在服务端上运行。
若相依 该用户已被删除
13#
发表于 2015-3-21 03:10:33 | 只看该作者
ASP也是这几种脚本语言中最简单易学的开发语言。但ASP也是这几种语言中唯一的一个不能很好支持跨平台的语言。  因为ASP脚本语言非常简单,因此其代码也简单易懂,结合HTML代码,可快速地完成网站的应用程序。
只想知道 该用户已被删除
14#
发表于 2015-3-25 09:32:21 | 只看该作者
Request:从字面上讲就是“请求”,因此这个是处理客户端提交的东东的,例如Resuest.Form,Request.QueryString,或者干脆Request("变量名")
精灵巫婆 该用户已被删除
15#
发表于 2015-4-16 08:40:50 | 只看该作者
我认为比较好的方法是找一些比较经典的例子,每个例子比较集中一种编程思想而设计的。
爱飞 该用户已被删除
16#
发表于 2015-5-6 03:11:43 | 只看该作者
你可以通过继承已有的对象最大限度保护你以前的投资。并且C#和C++、Java一样提供了完善的调试/纠错体系。
兰色精灵 该用户已被删除
17#
发表于 2015-6-11 05:42:35 | 只看该作者
Server:这个表示的服务器,操作服务器的一些东西使用这个,如Server.Mappath转换服务器路径,Server.CreateObject实例化一个组件
灵魂腐蚀 该用户已被删除
18#
发表于 2015-6-11 16:11:41 | 只看该作者
代码的可重用性差:由于是面向结构的编程方式,并且混合html,所以可能页面原型修改一点,整个程序都需要修改,更别提代码重用了。
乐观 该用户已被删除
19#
发表于 2015-6-27 12:23:42 | 只看该作者
在平时的学习过程中要注意现学现用,注重运用,在掌握了一定的基础知识后,我们可以尝试做一些网页,也许在开始的时候我们可能会遇到很多问题,比如说如何很好的构建基本框架。
admin 该用户已被删除
20#
发表于 2015-7-11 06:42:14 | 只看该作者
跟学别的语言一样,先掌握变量,流程控制语句(就是ifwhileselect)等,函数/过程,数组
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|仓酷云 鄂ICP备14007578号-2

GMT+8, 2024-5-3 14:30

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表