Results 1 to 2 of 2

Thread: A simple registration form

  1. #1
    Join Date
    Oct 2002
    Posts
    933

    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>

  2. #2
    Join Date
    Oct 2002
    Posts
    933

    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>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •