36 users online (1 members and 35 guests)  

Thread: asp questions


Page 1 of 2 1 2 Last
  Results 1 to 15 of 27

Related

  1. some php questions    Forum: PHP Forum
    Replies: 0
  2. 3 questions    Forum: CGI Perl Forum
    Replies: 2
  3. How to do this in CSS? A few questions.    Forum: CSS Forum
    Replies: 0
  4. Six Questions    Forum: HTML Forum
    Replies: 4
  5. Questions...    Forum: HTML Forum
    Replies: 1
  1. #1
    springo707's Avatar
    Junior Member

    Status
    Offline
    Join Date
    Jul 2002
    Location
    Kansas City MO
    Posts
    42

    asp questions

    I need to set up a basic form. I am working on a site for someone and their server only supports asp. The only thing I have ever used before was formmail.cgi from Matt's script archive - I'm sure most people are familiar.

    Does asp work in the same manner? One page with the form that the visitor fills out and then a second file to process/handle/email/whatever the form?

    Thanks for any help

    David

  2. #2
    Zaire's Avatar
    Senior Member

    Status
    Offline
    Join Date
    Mar 2001
    Location
    Hamburg, NY
    Posts
    312
    Works the same way, all you need to do is:

    1) Show me the form you want to process
    2) Tell me where you want the results stored
    3) Are there any special matching needed? Certin Fields required?

  3. #3
    Doorknob's Avatar
    Super Newbie

    Status
    Offline
    Join Date
    Jun 2002
    Location
    Malaysia
    Posts
    316

    RE

    the first page is the form, and all data entry/client side validation (required fields,integers only etc) should be done there, the second page processes the info, and server side validation (if any are needed) is handled here.

    u can insert the data into a database, send an email, write the info into a file etc. if you're unfamiliar with asp, just search the web for sites that deal with the basics. there are many around, or u can just ask and somebody will reply with a recommendation. processing forms is extremely easy using asp

    have fun!

  4. #4
    springo707's Avatar
    Junior Member

    Status
    Offline
    Join Date
    Jul 2002
    Location
    Kansas City MO
    Posts
    42

    thanks

    have not been on-line in several days - thanks for the responses. That explains a little bit more. Will try to figure it out from here - at least I now understand basically how the script and all works.

    Found some stuff on a site called brainjar.com and will work with that.

    Thanks again for the suggestions.

    David

  5. #5
    springo707's Avatar
    Junior Member

    Status
    Offline
    Join Date
    Jul 2002
    Location
    Kansas City MO
    Posts
    42

    ok, so I can't figure it out...

    This is what I have for the form:

    <form action="formmail.asp" method="post">
    <input name="_recipients" type="hidden" value="np@nabity-perry.com">
    <input name="_requiredFields" type="hidden"
    value="Name,Customer ID,Email,Comments">
    Name: <input name="Name" type="text"><br>
    Customer ID: <input name="Customer ID" type="text"><br>
    Email Address: <input name="Email" type="text"><br>
    Comments:<br>
    <textarea name="Comments" rows=5 cols=50></textarea>
    <input type="submit" value="Submit">
    <input type="reset" value="Clear">
    </form>

    In formmail.asp, I believe I have the relevant variables set correctly:

    referers = Array("www.nabity-perry.com", "nabity-perry.com")
    mailComp = "ASPMail"
    smtpServer = "smtp.nabity-perry.com"
    fromAddr = "guest@nabity-perry.com"


    I have formmail.asp in the root directory of the site and every time I submit the form I get 503 No Recipients Specified. If I am reading correctly, I do have them specified. The for is exactly as posted above and the formmail.asp file I got from brainjar.com.

    Any ideas as to what I am doing wrong?

  6. #6
    QuietDean's Avatar
    Administrator

    Status
    Offline
    Join Date
    Oct 2000
    Location
    Bournemouth, UK
    Posts
    2,662
    Could you post your version of formail.asp ? edit out any sensitive info.
    If one of our members helps you, please click the icon to add to their reputation!
    No support via email or private message - use the forums!
    Before you ask, have you Searched?

  7. #7
    springo707's Avatar
    Junior Member

    Status
    Offline
    Join Date
    Jul 2002
    Location
    Kansas City MO
    Posts
    42
    Life has slapped me around enough - not overly concerned with sensitivity:-)

    <%@ LANGUAGE="VBScript" %>

    <% '***************************************************************************
    '* ASP FormMail *
    '* *
    '* Do not remove this notice. *
    '* *
    '* Copyright 1999-2002 by Mike Hall. *
    '* Please see http://www.brainjar.com for documentation and terms of use. *
    '***************************************************************************

    '- Customization of these values is required, see documentation. -----------

    referers = Array("www.nabity-perry.com", "nabity-perry.com")
    mailComp = "ASPMail"
    smtpServer = "smtp.nabity-perry.com"
    fromAddr = "email removed"

    '- End required customization section. -------------------------------------

    Response.Buffer = true
    errorMsgs = Array()

    'Check for form data.

    if Request.ServerVariables("Content_Length") = 0 then
    call AddErrorMsg("No form data submitted.")
    end if

    'Check if referer is allowed.

    validReferer = false
    referer = GetHost(Request.ServerVariables("HTTP_REFERER"))
    for each host in referers
    if host = referer then
    validReferer = true
    end if
    next
    if not validReferer then
    if referer = "" then
    call AddErrorMsg("No referer.")
    else
    call AddErrorMsg("Invalid referer: '" & referer & "'.")
    end if
    end if

    'Check for the recipients field.

    if Request.Form("_recipients") = "" then
    call AddErrorMsg("Missing email recipient.")
    end if

    'Check all recipient email addresses.

    recipients = Split(Request.Form("_recipients"), ",")
    for each name in recipients
    name = Trim(name)
    if not IsValidEmail(name) then
    call AddErrorMsg("Invalid email address in recipient list: " & name & ".")
    end if
    next
    recipients = Join(recipients, ",")

    'Get replyTo email address from specified field, if given, and check it.

    name = Trim(Request.Form("_replyToField"))
    if name <> "" then
    replyTo = Request.Form(name)
    else
    replyTo = Request.Form("_replyTo")
    end if
    if replyTo <> "" then
    if not IsValidEmail(replyTo) then
    call AddErrorMsg("Invalid email address in reply-to field: " & replyTo & ".")
    end if
    end if

    'Get subject text.

    subject = Request.Form("_subject")

    'If required fields are specified, check for them.

    if Request.Form("_requiredFields") <> "" then
    required = Split(Request.Form("_requiredFields"), ",")
    for each name in required
    name = Trim(name)
    if Left(name, 1) <> "_" and Request.Form(name) = "" then
    call AddErrorMsg("Missing value for " & name)
    end if
    next
    end if

    'If a field order was given, use it. Otherwise use the order the fields were
    'received in.

    str = ""
    if Request.Form("_fieldOrder") <> "" then
    fieldOrder = Split(Request.Form("_fieldOrder"), ",")
    for each name in fieldOrder
    if str <> "" then
    str = str & ","
    end if
    str = str & Trim(name)
    next
    fieldOrder = Split(str, ",")
    else
    fieldOrder = FormFieldList()
    end if

    'If there were no errors, build the email note and send it.

    if UBound(errorMsgs) < 0 then

    'Build table of form fields and values.

    body = "<table border=""0"" cellpadding=""2"" cellspacing=""0"">" & vbCrLf
    for each name in fieldOrder
    body = body _
    & "<tr valign=""top"">" _
    & "<td><b>" & name & ":</b></td>" _
    & "<td>" & Request.Form(name) & "</td>" _
    & "</tr>" & vbCrLf
    next
    body = body & "</table>" & vbCrLf

    'Add a table with any environmental variables.

    if Request.Form("_envars") <> "" then
    body = body _
    & "<p>&nbsp;</p>" & vbCrLf _
    & "<table border=""0"" cellpadding=""2"" cellspacing=""0"">" & vbCrLf
    envars = Split(Request.Form("_envars"), ",")
    for each name in envars
    name = Trim(name)
    body = body _
    & "<tr valign=""top"">" _
    & "<td><b>" & name & ":</b></td>" _
    & "<td>" & Request.ServerVariables(name) & "</td>" _
    & "</tr>" & vbCrLf
    next
    body = body & "</table>" & vbCrLf
    end if

    'Send it.

    str = SendMail()
    if str <> "" then
    AddErrorMsg(str)
    end if

    'Redirect if a URL was given.

    if Request.Form("_redirect") <> "" then
    Response.Redirect(Request.Form("_redirect"))
    end if

    end if %>

    <html>
    <head>
    <title>Form Mail</title>
    <style style="text/css">

    body {
    background-color: #ffffff;
    color: #000000;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 10pt;
    }

    table {
    border: solid 1px #000000;
    border-collapse: collapse;
    }

    td, th {
    border: solid 1px #000000;
    border-collapse: collapse;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 10pt;
    padding: 2px;
    padding-left: 8px;
    padding-right: 8px;
    }

    th {
    background-color: #c0c0c0;
    }

    .error {
    color: #c00000;
    }

    </style>
    </head>
    <body>

    <% if UBound(errorMsgs) >= 0 then %>
    <p class="error">Form could not be processed due to the following errors:</p>
    <ul>
    <% for each msg in errorMsgs %>
    <li class="error"><% = msg %>
    <% next %>
    </ul>
    </td></tr></table>
    <% else %>
    <table cellpadding="0" cellspacing="0">
    <tr>
    <th colspan="2" valign="bottom">
    Thank you, the following information has been sent:
    </th>
    </tr>
    <% for each name in fieldOrder %>
    <tr valign="top">
    <td><b><% = name %></b></td>
    <td><% = Request.Form(name) %></td>
    </tr>
    <% next %>
    </table>
    <% end if %>

    </body>
    </html>

    <% '---------------------------------------------------------------------------
    ' Subroutines and functions.
    '---------------------------------------------------------------------------

    sub AddErrorMsg(msg)

    dim n

    'Add an error message to the list.

    n = UBound(errorMsgs)
    Redim Preserve errorMsgs(n + 1)
    errorMsgs(n + 1) = msg

    end sub

    function GetHost(url)

    dim i, s

    GetHost = ""

    'Strip down to host or IP address and port number, if any.

    if Left(url, 7) = "http://" then
    s = Mid(url, 8)
    elseif Left(url, 8) = "https://" then
    s = Mid(url, 9)
    end if
    i = InStr(s, "/")
    if i > 1 then
    s = Mid(s, 1, i - 1)
    end if

    getHost = s

    end function

    function IsValidEmail(email)

    dim names, name, i, c

    'Check for valid syntax in an email address.

    IsValidEmail = true
    names = Split(email, "@")
    if UBound(names) <> 1 then
    IsValidEmail = false
    exit function
    end if
    for each name in names
    if Len(name) <= 0 then
    IsValidEmail = false
    exit function
    end if
    for i = 1 to Len(name)
    c = Lcase(Mid(name, i, 1))
    if InStr("abcdefghijklmnopqrstuvwxyz_-.", c) <= 0 and not IsNumeric(c) then
    IsValidEmail = false
    exit function
    end if
    next
    if Left(name, 1) = "." or Right(name, 1) = "." then
    IsValidEmail = false
    exit function
    end if
    next
    if InStr(names(1), ".") <= 0 then
    IsValidEmail = false
    exit function
    end if
    i = Len(names(1)) - InStrRev(names(1), ".")
    if i <> 2 and i <> 3 then
    IsValidEmail = false
    exit function
    end if
    if InStr(email, "..") > 0 then
    IsValidEmail = false
    end if

    end function

    function FormFieldList()

    dim str, i, name

    'Build an array of form field names ordered as they were received.

    str = ""
    for i = 1 to Request.Form.Count
    for each name in Request.Form
    if Left(name, 1) <> "_" and Request.Form(name) is Request.Form(i) then
    if str <> "" then
    str = str & ","
    end if
    str = str & name
    exit for
    end if
    next
    next
    FormFieldList = Split(str, ",")

    end function

    function SendMail()

    dim mailObj
    dim addrList

    'Send email based on mail component. Uses global variables for parameters
    'because there are so many.

    SendMail = ""

    'Send email (CDONTS version), doesn't support reply-to address and has
    'no error checking.

    if mailComp = "CDONTS" then
    set mailObj = Server.CreateObject("CDONTS.NewMail")
    mailObj.BodyFormat = 0
    mailObj.MailFormat = 0
    mailObj.From = fromAddr
    mailObj.To = recipients
    mailObj.Subject = subject
    mailObj.Body = body
    mailObj.Send
    end if

    'Send email (JMail version).

    if mailComp = "JMail" then
    set mailObj = Server.CreateObject("JMail.SMTPMail")
    mailObj.Silent = true
    mailObj.ServerAddress = smtpServer
    mailObj.Sender = fromAddr
    mailObj.ReplyTo = replyTo
    mailObj.Subject = subject
    addrList = Split(recipients, ",")
    for each addr in addrList
    mailObj.AddRecipient Trim(addr)
    next
    mailObj.ContentType = "text/html"
    mailObj.Body = body
    if not mailObj.Execute then
    SendMail = "Email send failed: " & mailObj.ErrorMessage & "."
    end if
    end if

    'Send email (ASPMail version).

    if mailComp = "ASPMail" then
    set mailObj = Server.CreateObject("SMTPsvg.Mailer")
    mailObj.FromAddress = fromAddr
    mailObj.RemoteHost = smtpServer
    mailObj.ReplyTo = replyTo
    for each addr in Split(recipients, ",")
    mailObj.AddRecipient "", Trim(addr)
    next
    mailObj.Subject = subject
    mailObj.ContentType = "text/html"
    mailObj.BodyText = body
    if not mailObj.SendMail then
    SendMail = "Email send failed: " & mailObj.Response & "."
    end if
    end if

    end function %>

  8. #8
    QuietDean's Avatar
    Administrator

    Status
    Offline
    Join Date
    Oct 2000
    Location
    Bournemouth, UK
    Posts
    2,662
    And whats the exact error you r getting?
    If one of our members helps you, please click the icon to add to their reputation!
    No support via email or private message - use the forums!
    Before you ask, have you Searched?

  9. #9
    springo707's Avatar
    Junior Member

    Status
    Offline
    Join Date
    Jul 2002
    Location
    Kansas City MO
    Posts
    42
    Form could not be processed due to the following errors:

    Email send failed: 503 No recipients specified.

  10. #10
    QuietDean's Avatar
    Administrator

    Status
    Offline
    Join Date
    Oct 2000
    Location
    Bournemouth, UK
    Posts
    2,662
    Try changing (to localize the problem) -

    Code:
    'Send email (ASPMail version).
    
    if mailComp = "ASPMail" then
    set mailObj = Server.CreateObject("SMTPsvg.Mailer")
    mailObj.FromAddress = fromAddr
    mailObj.RemoteHost = smtpServer
    mailObj.ReplyTo = replyTo
    for each addr in Split(recipients, ",")
    mailObj.AddRecipient "", Trim(addr)
    next
    mailObj.Subject = subject
    mailObj.ContentType = "text/html"
    mailObj.BodyText = body
    if not mailObj.SendMail then
    SendMail = "Email send failed: " & mailObj.Response & "."
    end if
    end if
    to

    Code:
    'Send email (ASPMail version).
    
    if mailComp = "ASPMail" then
    set mailObj = Server.CreateObject("SMTPsvg.Mailer")
    mailObj.FromAddress = fromAddr
    mailObj.RemoteHost = smtpServer
    mailObj.ReplyTo = replyTo
    
    
    mailObj.AddRecipient "you@emailaddress.com"
    
    mailObj.Subject = subject
    mailObj.ContentType = "text/html"
    mailObj.BodyText = body
    if not mailObj.SendMail then
    SendMail = "Email send failed: " & mailObj.Response & "."
    end if
    end if
    or failing that -

    mailObj.AddRecipient "", "you@emailaddress.com"

    Lets see what it says.
    If one of our members helps you, please click the icon to add to their reputation!
    No support via email or private message - use the forums!
    Before you ask, have you Searched?

  11. #11
    springo707's Avatar
    Junior Member

    Status
    Offline
    Join Date
    Jul 2002
    Location
    Kansas City MO
    Posts
    42
    with that change, I get this error message:

    Microsoft VBScript runtime error '800a01c2'

    Wrong number of arguments or invalid property assignment: 'mailObj.AddRecipient'

    /formmail.asp, line 383

  12. #12
    QuietDean's Avatar
    Administrator

    Status
    Offline
    Join Date
    Oct 2000
    Location
    Bournemouth, UK
    Posts
    2,662
    What about with the second version, just below it? -




    mailObj.AddRecipient "", "you@emailaddress.com"
    If one of our members helps you, please click the icon to add to their reputation!
    No support via email or private message - use the forums!
    Before you ask, have you Searched?

  13. #13
    springo707's Avatar
    Junior Member

    Status
    Offline
    Join Date
    Jul 2002
    Location
    Kansas City MO
    Posts
    42
    Hold on a second - I wasn't reading clearly - let me try again

  14. #14
    springo707's Avatar
    Junior Member

    Status
    Offline
    Join Date
    Jul 2002
    Location
    Kansas City MO
    Posts
    42
    I retried both, the first gives the error:
    with that change, I get this error message:

    Microsoft VBScript runtime error '800a01c2'

    Wrong number of arguments or invalid property assignment: 'mailObj.AddRecipient'

    /formmail.asp, line 383


    the second just gives the error 503 no recipient specified

  15. #15
    QuietDean's Avatar
    Administrator

    Status
    Offline
    Join Date
    Oct 2000
    Location
    Bournemouth, UK
    Posts
    2,662
    Try -



    mailObj.AddRecipient "you@emailaddress.com", ""
    If one of our members helps you, please click the icon to add to their reputation!
    No support via email or private message - use the forums!
    Before you ask, have you Searched?



Page 1 of 2 1 2 Last

Tags for this Thread