An ASP-based banner advertising management System (EXT) (ii)

Source: Internet
Author: User
Tags chr dsn functions interface
Advertisement second, management function

There are 12 ASP files in the Management Section, and the main functions of these scripts are as follows:

Banneradminlogin.asp: Login page for admin function. The default user name is "ADMIN user" and the password is "PASSWORD".
checkbanneradministrationpassword.asp: Check the password of the user who is using the administrative function.
Notloggedin.asp: The "no login" Prompt page, which is displayed if you access the Administration page before you log on.
Banneradministration.asp: This is the main interface of the admin function, listing all the ads and providing two buttons. These two buttons are used for new ads and new advertisers, respectively. Click on the Advertiser name to edit the Advertiser and click on the ad text to edit the ad.
Advertisement.asp: Enter the information for the new ad, or edit the current ad message, or call deleteadvertisement.asp to delete the current AD.
Advertiser.asp: Enter information for new advertisers, or edit current advertiser information, or call
Deleteadvertiser.asp deletes the current advertiser.
Addadvertisement.asp: Add ad Records, get information from advertisement.asp forms, and store them in a database.
Addadvertiser.asp: New advertiser record, get information from advertiser.asp form, store to database.
Updateadvertisement.asp: Gets information from the advertisement.asp form and updates records in the database that have the same advertisementid as the current AD.
Updateadvertiser.asp: Gets advertiser.asp form information to update records in the database that have the same advertiserid as the current advertiser.
Deleteadvertisement.asp: Deletes the corresponding record in the database according to the AdvertisementID of the currently selected advertisement. Note: It is sometimes necessary to refresh after removing and returning to the admin main interface.
Deleteadvertiser.asp: Deletes the corresponding database record according to the Advertiserid of the currently selected advertiser.


"Figure 1"

Complete code is downloaded from the end of this article. Assuming all files are in the inetpubscripts directory, the URL for the login management feature is: http://localhost/scripts/BannerAdminLogin.asp. All other features are accessible from this point in the beginning.

Next we'll introduce some of the key issues in the management functionality script.

㈠ Security

Most pages that perform administrative functions are password protected, and these pages check a session variable to confirm that the user has successfully logged in before performing its task. The check code looks like this:

' Check if the user is logged in
If session ("LoggedIn") <> true Then
Response.Redirect ("notloggedin.asp")
End If
The security mechanism used here is simpler, and more on the authentication of user identities in ASP applications.

㈡ List all the ads

When the Banneradministration.asp page starts, all the ad records in the database are listed. This part of the functionality is done through a simple query and a Recordset object, as follows:

' List all ads in the database
Set cn = Server.CreateObject ("ADODB.") Connection ")
cn. Open "Bannerbuddy"
Set rs = Server.CreateObject ("ADODB.") RECORDSET ")
Set rs2 = Server.CreateObject ("ADODB. RECORDSET ")
strSQL = "SELECT * from Advertisement"
Rs. Open strSQL, CN
Strcrlf = CHR (+) + CHR (10)
While not Rs. EOF and not Rs. BOF
' Find the customer name based on the Advertiser number (Advertiserid)
strSQL = "Select Name from advertiser where Advertiserid =" + _
CStr (Rs. Fields ("Advertiserid"))
Rs2. Open strSQL, CN
Stradvertiser = ""
If not rs2. EOF and not rs2. BOF Then
Stradvertiser = rs2. Fields ("Name")
End If
Response.Write ("</tr>" + Strcrlf)
Rs2. Close
Rs. MoveNext
Wend
The system assumes that the ODBC DSN for the database db.mdb is Bannerbuddy, so you must set up this DSN before running the program. For more information on database connections and operations, see the selection and filtering of database records in ASP applications.

In the ad list, click The Advertiser's name to edit the advertiser's information, click the text in the text/graphics bar to edit the message, and click the picture link to view the picture.

㈢ New and modified advertising and advertising customers

The task of the addadvertisement.asp and addadvertiser.asp scripts is to get the form data that is submitted to them, to create an advertiser or AD database record. The following code is used for new ad records, and the New Advertiser (addadvertiser.asp) code is similar.

' Connect to database, create Recordset object RS, slightly ...
Strstartdate = Request.Form ("startmonth") + "/" + _
Request.Form ("StartDay") + "/" + _
Request.Form ("StartYear")
Strenddate = Request.Form ("endmonth") + "/" + _
Request.Form ("Endday") + "/" + _
Request.Form ("Endyear")
 
Nstatus = 1
If UCase (Request.Form ("Status") = "INACTIVE" Then
Nstatus = 0
End If
 
' By the name of The Advertiser selected, get its number
Nadvertiserid = 1
strSQL = "Select Advertiserid from advertiser where Name = '" + _
Request.Form ("Advertiser") + "'"
Rs. Open strSQL, CN
If not Rs. EOF and not Rs. BOF Then
Nadvertiserid = Rs. Fields ("Advertiserid")
If IsNull (Nadvertiserid) Then
Nadvertiserid = 1
End If
End If



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.