亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb

首頁 > 學院 > 開發設計 > 正文

一個免費的郵件列表源程序(三)

2019-11-18 22:27:29
字體:
來源:轉載
供稿:網友
Subscribe.asp
<%@ Language=javaScript %>

<!--#include file = "include/SetGlobals.asp"-->
<!--#include file = "include/DBPath.asp"-->

<%
// output relevant meta tags
Init( "Subscription" );

// output common top of page
Header( '<a href="work.asp">Work</a> --> Subscription', 3 );

// output page content
Content ( );

// output common bottom of page
Footer( );
%>

<% /* standard page elements */ %>
<!--#include file = "utils/Init.asp"-->
<!--#include file = "utils/Database.asp"-->
<!--#include file = "utils/Header.asp"-->
<!--#include file = "utils/Footer.asp"-->

<%
// ============================================
// the content of this page
// ============================================
function Content ( )
{
   Out ( '<td width="20%">&nbsp;</td>' );
   Out ( '<td width="60%">' );
    
      // if the form has an email address, validate it first
      // so that if it fails we can show the form to fix
      var sEmail = "";
      var bSubmitted = (Request.Form.Count > 0);

      // has the form been submitted?
      if ( bSubmitted )
      {
         // get the email address from the form...
          sEmail = "" + Request.Form ( "email" );

         // validate the email address and moan if it fails
         if ( !IsValidEmail ( sEmail ) )
         {
            Out ( '<h5><font color="red">"' + sEmail + '" <i>appears</i> to be an invalid email address - please try again!</font></h5>' );
            Out ( '<p><font color="red">If you disagree, please <a href="Contact.asp">contact me</a> directly.</font><p>' );
            // PRetend the form hasn'/t been sent yet
            bSubmitted = false;
         }
      }

      // show the form if not submitted yet
      if ( !bSubmitted )
      {
         Out ( 'If you/'re interested in hearing whenever a new article is posted, or an existing one is updated, type in your email address below and hit <b>Subscribe!</b>' );
         Out ( '<p>Whenever you want to stop receiving my emails, guess what? That/'s right, enter your email address and hit <b>Unsubscribe</b>...' );
         Out ( '<p><i>Your email address will never sold to or otherwise used by any third party, just me.</i>' );

         // here's the form tag. the action attribute is the name of
         // the file that will be called with the answer - in this case
         // it's the same page. the method can be "post" to send the
         // form data 'behind the scenes' or "get" to appending the
         // data to the URL in the style page.asp?data1=a&data2=b
         //
         // use post most of the time - it's neater and "get" is limited
         // in the amount of data that can be sent.
         Out ( '<center><form action="Subscribe.asp" method="post">' );
    
            // another table to line up the titles and inputs
            Out ( '<table border="0" cellpadding="0">' );
            Out ( '<tr><td align="right" valign="top">' );
               Out ( 'Email:' );
            Out ( '</td><td align="left" valign="top">' );
               // a simple text box. we'll reference it with the name "name"
               // and show 22 characters on the form. use the maxlength
               // attribute to set the maximum characters they can enter.
               // use value="some text" to pre-fill the input with data.
               //
               // IMPORTANT! using names that are commonly used by
               // other web sites has a big advantage to the user - IE
               // will drop down a list of previous answers, which they
               // can usually pick from rather than type in. Think about this.
               Out ( '<input type="text" name="email" size="31" value="' + sEmail + '"></input>' );
            Out ( '</td></tr>' );

            Out ( '<tr><td align="right" valign="top">' );
               Out ( '&nbsp;' );
            Out ( '</td><td align="left" valign="top">' );
               // type='submit" provides a submit button to perform the
               // form action. the button says "Submit" unless you override
               // with the value attribute.
               Out ( '<input type="submit" name="action" value="Subscribe"></input>&nbsp;<input type="submit" name="action" value="Unsubscribe"></input>' );
            Out ( '</td></tr>' );

            Out ( '</table>' );
         Out ( '</form></center>' );
      }
      else
      {
         var sAction = "" + Request.Form ( "action" );

         if ( sAction == "Subscribe" )
            AddEmail ( sEmail ) ;
         else
            RemoveEmail ( sEmail );

         Out ( '<p>' );
      }

      Out ( 'Do you want to see how this form adds and removes addresses to my database? All the source code is just a click away!' );
      Out ( '<p><center><a href="ShowSource.asp? page=Subscribe"><img src="images/source.gif" border=0></a></center>' );
      Out ( '<p>In <a href="MailToList.asp">Part 2</a> see how I wrote a form to mail all my subscribers...' );

   Out ( '</td>' );
   Out ( '<td width="20%">&nbsp;</td>' );
}

// ============================================
// validate email address
// ============================================
function IsValidEmail ( sEmail )
{
   // regular expression courtesy of ed.courtenay@nationwideisp.net
   // I won't even pretend that I've read through this yet!

   if ( sEmail.search ( //w+((-/w+)|(/./w+)|(/_/w+))*/@[A-Za-z0-9]+((/.|-)[A-Za-z0- 9]+)*/.[A-Za-z]{2,5}/ ) != -1 )
      return true;
   else
      return false;
}


// ============================================
// add email to database
// ============================================
function AddEmail ( sEmail )
{       
   // open the connection
   DBInitConnection ( );

   // first see if they are already subscribed
   var sSQL = 'SELECT Email FROM MailingList WHERE Email="' + sEmail + '";';

   DBGetRecords ( sSQL );

   if ( !oRecordSet.EOF )
   {
      Out ( '<h5><font color="red">' + sEmail + ' is already subscribed to my mailing list!</font></h5>' );
      return;
   }

   // this section needs more work - what should be done is that an email is
   // sent to the email address, and only added to the database when we
   // get a reply. that way we know the address is valid and the recipient
   // really wants to join the list. for now though, we'll add to the db now.
   sSQL = 'INSERT INTO MailingList (Email) VALUES ("' + sEmail + '");';

   oConnection.Execute( sSQL );

   // free the connection
   DBReleaseConnection ( );

   Out ( sEmail + ' has been successfully subscribed to my mailing list. ' );
   Out ( '<p>You will now receive an email whenever I write new articles, or if I make an important update to any.' );

   Email ( 'Joined the ShawThing mailing list', sEmail, 'You have successfully subscribed to the mailing list at ShawThing. If you didn/'t request this please reply to this email, or visit http://www.shawthing.com/subscribe.asp to unsubscribe./n/nThank you./n/nJames Shaw/nhttp://www.shawthing.com/' );
}


// ============================================
// remove email from database
// ============================================
function RemoveEmail ( sEmail )
{       
   // open the connection
   DBInitConnection ( );

   // first see if they are already subscribed
   var sSQL = 'SELECT Email FROM MailingList WHERE Email="' + sEmail + '";';

   DBGetRecords ( sSQL );

   if ( oRecordSet.EOF )
   {
      Out ( '<h5><font color="red">' + sEmail + ' isn/'t subscribed to my mailing list!</font></h5>' );
      return;
   }

   // delete from the database
   sSQL = 'DELETE FROM MailingList WHERE Email="' + sEmail + '";';

   oConnection.Execute( sSQL );

   // free the connection
   DBReleaseConnection ( );

   Out ( sEmail + ' has been successfully removed from my mailing list. ' );
   Out ( '<p>You have been sent a confirmation email, but after that you will not receive any more emails.' );

   Email ( 'Removal from ShawThing mailing list', sEmail, 'You have been successfully removed from the mailing list at ShawThing. If you didn/'t request this please reply to this email, or visit http://www.shawthing.com/subscribe.asp to re-subscribe./n/nThank you./n/nJames Shaw/nhttp://www.shawthing.com/' );
}


// ============================================
// email me!
// ============================================
function Email ( sSubject, sEmail, sMessage )
{   // send an email to the address just to confirm what just happened
   var oMail = Server.CreateObject ( "CDONTS.NewMail" );

   // setup the mail
   oMail.From = 'DB@shawthing.com';

   oMail.To = sEmail;
   oMail.Importance = 1;

   oMail.Subject = sSubject;
   oMail.Body = sMessage;

   // send it
   oMail.Send ( );

   // release object
   oMail = null;
}
%>
     
utils/Database.asp
<%
// globals
var oConnection;
var oRecordSet;
var sConnection;

// ============================================
// example usage:
//      DBInitConnection ( );
//
//      var sSQL = "SELECT * FROM Somewhere";
//
//      DBGetRecords ( sSQL );
//
//      ...use oRecordSet
//
//      DBReleaseRecords ( );      // optional step
//
//      DBReleaseConnection ( );
// ============================================

// ============================================
// initializes database variables for first use on page
// ============================================
function DBInitConnection ( )
{
   // don't open it again if already opened!
   if ( sConnection != undefined )
      return;
       
   // get connection object
   oConnection = Server.CreateObject( 'ADODB.Connection' );

   // get the database connection string
   // use MapPath to make relative path into physical path
   sConnection = 'Provider=Microsoft.Jet.OLEDB.4.0; Data Source=' + Server.MapPath ( sDBPath );

   // open the connection
   oConnection.Open( sConnection );

   // as an attempt at optimization we now open
   // the recordset here, not in DBGetRecords()
   oRecordSet = Server.CreateObject ( 'ADODB.Recordset' );
}

// ============================================
// tidies up after DBInitConnection
// ============================================
function DBReleaseConnection ( )
{
   // don't release the connection if not connected!
   if ( sConnection == undefined )
      return;
       
   // as an attempt at optimization we now close
   // the recordset here, not in DBReleaseRecords()
   if ( oRecordSet.State != 0 )
      oRecordSet.Close();
   oRecordSet = undefined;

   oConnection.Close();
   oConnection = undefined;
    
   sConnection = undefined;
}

// ============================================
// executes the passed in SQL statement
// and returns the oRecordSet object
// ============================================
function DBGetRecords ( sSQL )
{
   // remember that this can fail if passed garbage, and hence
   // 'oRecordSet' will already be 'closed'
   oRecordSet = oConnection.Execute( sSQL );
}

// ============================================
// tidies up after DBGetRecords
// ============================================
function DBReleaseRecords ( )
{
   // IMPORTANT: THIS FUNCTION INTENTIONALLY BLANK
   // as an attempt at optimization we now open/close
   // the recordset with the connection, not separately
   // so all code was moved to DBReleaseConnection.
    
   // it is recommended that you still call this function as soon
   // as the recordset is finished with.
    
   // note that it is assumed by the caller that it is legal
   // to call DBReleaseConnection without calling this function
}
%>


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb
日韩在线精品视频| 一本一本久久a久久精品综合小说| 国产日韩在线看片| 久久综合亚洲社区| 7777kkkk成人观看| 91视频8mav| 国产精品自拍偷拍视频| 久热在线中文字幕色999舞| 国产精品视频精品| 亚洲第一网站男人都懂| 国产精品女人久久久久久| 在线观看久久av| 亚洲精品视频久久| 国产亚洲精品va在线观看| 欧美丰满片xxx777| 久久视频在线播放| 亚洲一区二区久久久久久久| 伊人激情综合网| 一级做a爰片久久毛片美女图片| 欧美性猛交xxxx乱大交蜜桃| 亚洲精品白浆高清久久久久久| 91美女片黄在线观| 韩国v欧美v日本v亚洲| 国产成人精品久久| 亚洲一区二区国产| 91精品国产91久久久久福利| 日韩免费在线免费观看| 一区二区三区四区视频| 亚洲性日韩精品一区二区| 亚洲自拍偷拍色片视频| 亚洲精品视频免费在线观看| 日韩精品在线影院| 上原亚衣av一区二区三区| 欧美一级淫片videoshd| 国产日韩欧美日韩| 色www亚洲国产张柏芝| 国产精品激情av电影在线观看| 精品日韩中文字幕| 久久久久国色av免费观看性色| 麻豆国产va免费精品高清在线| 欧美日韩免费区域视频在线观看| 午夜精品99久久免费| 亚洲欧美日韩在线高清直播| 欧美激情性做爰免费视频| 粗暴蹂躏中文一区二区三区| 国产精品福利无圣光在线一区| 青草成人免费视频| 国产视频在线一区二区| 亚洲国产精品嫩草影院久久| 亚洲免费视频网站| 亚洲天堂av综合网| 日韩欧美精品网站| 91在线视频九色| 国产精品极品美女在线观看免费| 久久中文字幕在线| 国外成人性视频| 精品免费在线视频| 欧美性视频在线| 国产日韩中文字幕| 亚洲区bt下载| 国产91精品高潮白浆喷水| 九九热这里只有精品6| 久精品免费视频| 91亚洲精品视频| 久久亚洲精品毛片| 国产精品久久久久久久天堂| 亚洲欧洲偷拍精品| 国产精品久久久一区| 久久人人爽人人爽人人片av高请| 91精品国产九九九久久久亚洲| 97精品国产97久久久久久免费| 色香阁99久久精品久久久| 中文国产成人精品久久一| 国产精品女主播视频| 日韩av影视综合网| 91久久久久久久久久久| 2019中文字幕在线观看| 国产xxx69麻豆国语对白| 中文字幕综合一区| 欧美肥臀大乳一区二区免费视频| 国产精品一区二区3区| 亚洲激情在线观看| 国产亚洲综合久久| 一区二区亚洲精品国产| 久久成人人人人精品欧| 亚洲精品成人久久电影| 欧美精品一区三区| 国产精品xxx视频| 国产一区二区三区网站| 尤物tv国产一区| 亚洲一区二区久久久| 亚洲成人av片在线观看| 国产欧美久久一区二区| 成人av番号网| 亚洲高清一区二| 国产成人97精品免费看片| 国产精品视频白浆免费视频| 亚洲欧美中文日韩在线| 久久欧美在线电影| 国产精品网红福利| 日本欧美中文字幕| 欧美网站在线观看| 欧美激情免费视频| 欧美精品videos另类日本| 欧美在线免费看| 久久免费视频在线观看| 在线观看国产成人av片| 久久免费观看视频| 欧美极品欧美精品欧美视频| 人人澡人人澡人人看欧美| 亚洲成av人影院在线观看| 久99九色视频在线观看| 国产区精品在线观看| 亚洲四色影视在线观看| 国内精品视频一区| 3344国产精品免费看| 亚洲在线免费看| 亚洲欧美日韩在线一区| 国产精品久久久久免费a∨大胸| 久久久久久久国产精品| 欧美色视频日本版| 北条麻妃一区二区在线观看| 国产午夜精品视频免费不卡69堂| 4p变态网欧美系列| 亚洲人免费视频| 奇门遁甲1982国语版免费观看高清| 欧美午夜精品久久久久久久| 中文字幕不卡av| 91高清视频免费观看| 久久久久久久久久久91| 97超级碰在线看视频免费在线看| 国产精品18久久久久久麻辣| 亚洲精品电影网在线观看| 亚洲精品v天堂中文字幕| 久久久精品久久久| 在线精品91av| 91av在线看| 91精品国产91久久久| 欧美一二三视频| 国产精品成人免费视频| 国产精品久久久久久久电影| 欧美日韩亚洲一区二区| 欧美成人精品不卡视频在线观看| 欧美激情亚洲另类| 久久亚洲精品一区| 成人情趣片在线观看免费| 久久99视频精品| 影音先锋欧美精品| 色综合老司机第九色激情| 伊人亚洲福利一区二区三区| 精品一区二区三区四区在线| 精品日本高清在线播放| 色噜噜狠狠色综合网图区| 久久欧美在线电影| 国产精品亚洲美女av网站| 国产精国产精品| 国产精品日韩在线观看| 久久这里有精品| 国产日韩综合一区二区性色av| 精品国产欧美成人夜夜嗨| 九九久久久久久久久激情| 亚洲视频一区二区| 岛国av午夜精品| 日韩av在线影视|