To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here

HOME News MS SQL Oracle DB2 Access MySQL PHP Scripts Books Links DBA Talk


Go Back   Database Journal Forums > Miscellaneous > Database Programming

Database Programming Discussion on all database programming topics, including ASP-db, ASP.NET, ASP and PHP.

Reply Post New Thread
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1  
Old 12-15-2006, 12:01 AM
Frank Frank is offline
Super Moderator
 
Join Date: Oct 2002
Posts: 925
A simple registration form

Need a user registration form for my 2007 RFID World project and a quick look around found several MyInput and SilentCmdText examples and probably all I need. The following program is only 40 lines and it provides a good looking from for title select, input, validation for phone and email address and upon submits, it’ll add the record to the database and display a message. The entire process takes about 30 minutes. The program is divided into 2 parts separated by ASPdbPostBack. Once the submit button is clicked, it is then a Postback and part 2 will execute and save the record to the DB.

In the process, I updated the email reg exp to cover the latest addion url names like .name, .info etc. Watch out for the next release for that.

------------------------------------------------------

<script language="VB" runat="server">
Sub Page_Load(Src As Object, E As EventArgs)
Dim Mi As New Tornado.z
Dim db As String = Server.MapPath("/tornado/GD/RFIDWorld.mdb")
Mi.dbQP = "U=1|S=Airgate|th=tit=2007 RFID World Complementary Pass Request Form"
Mi.dbValidatorParams = "code=/tornado/Jars|entry=false"
Dim inp As String = "(;~)"
inp &= "Fi=Title| Ty=SelectBox| Val={{Mr.,Mrs.,Ms.,Dr.}}~"
inp &= "Fi=Name| type= TEXT| Tag=SIZE=50~"
inp &= "Fi=Company| type=TEXT| Tag=SIZE=50~"
inp &= "Fi=Position| type=TEXT| Tag=SIZE=50~"
inp &= "Fi=Phone| type=TEXT| Tag=SIZE=50|mask=USPHONE|event=both|req=true|err=I nvalid phone e.g. XXX-XXX-XXXX~"
inp &= "Fi=email| type=TEXT| Tag=SIZE=50|mask=EMAIL|event=both|req=true|err=Inv alid email address~"
inp &= "Fi=Application| type=TEXTAREA| Tag=COLS=50 ROWS=15 WRAP=True| Def=Airgate will pay for the $99 fee if we can provide a solution for your authentication problem. Please describe your product authentication problem here. If you are qualified, we'll send you the code to get your pass at the registration booth."
Mi.dbMyInputFlds = inp
Response.Write("<Center>" & Mi.ASPdbMyInputForm() & "</Center>")

If Mi.ASPdbPostBack Then
Dim log As String = CStr(Now())
Dim _title As String = Request.Form("Title").ToString
Dim _name As String = Request.Form("name").ToString
Dim _company As String = Request.Form("Company").ToString
Dim _position As String = Request.Form("Position").ToString
Dim _phone As String = Request.Form("Phone").ToString
Dim _email As String = Request.Form("Email").ToString
Dim _application As String = Request.Form("Application").ToString.Replace("'", "''")
Mi.dbQP = "u=1|Q=TB1|BM=TB1;0|Nh=t|D=" & db
Mi.dbDebug = "EditAction"
Dim val As String = "('" & _title & "','" & _name & "','" & _company & "','" & _position & "','" & _phone & "','" & _email & "','" & _application & "'," & "#" & log & "#)"
Mi.dbSilentCmdText = "com=INSERT INTO TB1 (tit,nam,company,pos,phone,email,application,tlog) VALUES " & val
If Mi.ASPdbExecuteCmd() > 0 Then
Response.Write("<h1>Thank you for your interest in Airgate Technologies<BR>We'll get back to you</h1>")
Else
Response.Write("<h1>Error in adding record to database</h1>")
End If
End If
End Sub
</script>
Reply With Quote
  #2  
Old 12-17-2006, 02:00 PM
Frank Frank is offline
Super Moderator
 
Join Date: Oct 2002
Posts: 925
Modification to the Input form

Turns out that the requirement of the user request form is to send email to notify various staff member when request come in. No problem, just add the ASPdbSendMail() and that'll do it. Also adjust the code to work in development and launch mail server environment aby detectin gthe SERVER_NAME and assign the appropriate SMTP server. Actually, the email option is very real and I added the trigger = add to the dbSilentCmdText for the next release. The difference is then user does not have to use ASPdbSendMail(), just specify the dbMail with trigger=add. Below is the modified code.

--------------------------------------------------

<script language="VB" runat="server">
Sub Page_Load(Src As Object, E As EventArgs)
Dim MyServer As String = Request.ServerVariables("SERVER_NAME")
Dim MySMTP As String = "smtp.comcast.net"
If InStr(1, MyServer, "airgate", 1) > 0 Then MySMTP = "localhost"
Dim GD As New Tornado.GetData
Dim Mi As New Tornado.z
Dim db As String = Server.MapPath("/tornado/GD/Airgate.mdb")
Mi.dbQP = "U=1|S=Airgate|th=tit=2007 RFID World Complementary Pass Request Form"
Mi.dbValidatorParams = "code=/tornado/Jars|entry=false"
Dim inp As String = "(;~)"
inp &= "Fi=Title| Ty=SelectBox| Val={{Mr.,Mrs.,Ms.,Dr.}}~"
inp &= "Fi=Name| type= TEXT| Tag=SIZE=50~"
inp &= "Fi=Company| type=TEXT| Tag=SIZE=50~"
inp &= "Fi=Position| type=TEXT| Tag=SIZE=50~"
inp &= "Fi=Phone| type=TEXT| Tag=SIZE=50|mask=USPHONE|event=both|req=true|err=I nvalid phone e.g. XXX-XXX-XXXX~"
inp &= "Fi=email| type=TEXT| Tag=SIZE=50|mask=EMAIL|event=both|req=true|err=Inv alid email address~"
inp &= "Fi=Application| type=TEXTAREA| Tag=COLS=50 ROWS=15 WRAP=True| Def=Airgate will pay for the $99 fee if we can provide a solution for your authentication problem. Please describe your product authentication problem here. If you are qualified, we'll send you the code to get your pass at the registration booth."
Mi.dbMyInputFlds = inp
Response.Write("<Center>" & Mi.ASPdbMyInputForm() & "</Center>")

If Mi.ASPdbPostBack Then
Dim log As String = CStr(Now())
Dim _title As String = Request.Form("Title").ToString
Dim _name As String = Request.Form("name").ToString
Dim _company As String = Request.Form("Company").ToString
Dim _position As String = Request.Form("Position").ToString
Dim _phone As String = Request.Form("Phone").ToString
Dim _email As String = Request.Form("Email").ToString
Dim _application As String = Request.Form("Application").ToString.Replace("'", "''")
Mi.dbQP = "u=1|Q=TB1|BM=TB1;0|Nh=t|D=" & db
Mi.dbDebug = "EditAction"
Dim val As String = String.Format("('{0}','{1}','{2}','{3}','{4}','{5} ','{6}',#{7}#)", _title, _name, _company, _position, _phone, _email, _application, log)
Mi.dbSilentCmdText = "com=INSERT INTO TB1 (tit,nam,company,pos,phone,email,application,tlog) VALUES " & val
If Mi.ASPdbExecuteCmd() > 0 Then
Response.Write("<h2>Thank you for your interest in Airgate Technologies<BR>We'll get back to you</h2>")
Mi.dbMail = String.Format("test=false| smtp={9}| From={0}|to=frank.kwong@airgatetech.com;info@airga tetech.com|subject=Free Pass Request |Body=Free Pass Request Info -<br>Name={1} {2}<BR>Company={3}<br>Position={4}<br>Phone={5}<br >email={6}<br>Application={7}<br>Time={8}", _email, _title, _name, _company, _position, _phone, _email, _application, log, MySMTP)
Mi.ASPdbSendMail()
Else
Response.Write("<h2>Error in adding record to database</h2>")
End If
End If
End Sub
</script>
Reply With Quote
Reply Post New Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 05:36 AM.


DatabaseJournal Recent Articles


 » Configuring Oracle as a Data Source for SQ...

 » Tips for Simplifying Crosstab Query Statem...

 » Redmond exploits MySQL uncertainty

 » Oracle Launches Oracle Global Trade Manage...

 » SQL Server 2008 RTM Support Ends April 13,...

Search Database Journal:
 








Acceptable Use Policy


The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers

Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.