Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Web form help

Options
  • 17-10-2007 2:11pm
    #1
    Registered Users Posts: 3,056 ✭✭✭


    Hey all,

    I'm trying to amend a web form for a client... the code was written by the first web designer.

    It did work...

    The client asked me to change the mailto email to another, so I opened the form in Dreamweaver and changed the mailto to the new one and uplaoded it - But now I'm getting this message when I try to send a test mail online:

    Microsoft VBScript runtime error '800a0009'

    Subscript out of range: '[number: 2]'

    /cgi-bin/formmail.asp, line 96


    I've marked line 96 for you...
    I'm probably missing something small...!

    Here's the actual old site with my amended email - info@summerhillspares.ie
    http://www.summerhillspares.ie/

    HERES THE CODE:





    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;
    <html>
    <head>
    <title>Summerhill Auto Recycling, used car parts, end of life</title>


    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>

    <body bgcolor="#ffffff">

    <a href="http://www.summerhillspares.ie/requestprocessed.htm"><img src="images/SummerhillSparesTopofpage.jpg" alt="" border="0" style="width: 762px; height: 396px;"></a>

    <form ACTION="cgi-bin/formmail.asp" method="get" name="form1">
    <input name="recipient" value="info@summerhillspares.ie" type="hidden">
    <input type="hidden" name="redirect" value="http://www.summerhillspares.ie/requestprocessed.htm"&gt;
    <input name="subject" type="hidden" id="subject" value="spare parts request">

    <table width="760" border="1" cellpadding="1" cellspacing="1" bgcolor="#006600">

    <tbody>
    <tr bgcolor="006600">


    <td width="171"><font color="CCCCCC" face="Arial, Helvetica, sans-serif" size="3">
    Your Name</font></td>

    <td width="576"><font color="006600" face="Arial, Helvetica, sans-serif" size="2">
    <input name="CustomerName" id="CustomerName" type="text">
    </font></td>

    </tr>

    <tr bgcolor="006600">


    <td><font color="CCCCCC" face="Arial, Helvetica, sans-serif" size="3">Phone
    Number </font></td>

    <td><font color="CCCCCC" face="Arial, Helvetica, sans-serif" size="2">
    <input name="PhoneNumber" id="PhoneNumber2" type="text">

    </font></td>

    </tr>


    <tr>
    <td bgcolor="006600"><font color="CCCCCC" face="Arial, Helvetica, sans-serif" size="3">email
    address </font></td>


    <td bgcolor="006600"><font color="CCCCCC" face="Arial, Helvetica, sans-serif" size="3">
    <input name="EmailAddress" id="EmailAddress2" type="text">
    </font></td>

    </tr>

    <tr>
    <td bgcolor="006600"><font color="CCCCCC" face="Arial, Helvetica, sans-serif" size="3">Make
    of Vehicle/Car</font></td>


    <td bgcolor="006600"><font color="CCCCCC" face="Arial, Helvetica, sans-serif" size="2">
    <input name="CarMake" id="CarMake2" type="text">
    </font></td>

    </tr>

    <tr bgcolor="006600">


    <td><font color="CCCCCC" face="Arial, Helvetica, sans-serif" size="3">Model,
    eg. 1.6, 5 door</font></td>

    <td><font color="CCCCCC" face="Arial, Helvetica, sans-serif" size="3">
    <input name="ModelofCar" id="CarMake2" type="text">
    </font></td>

    </tr>

    <tr>



    <td bgcolor="006600"><font color="CCCCCC" face="Arial, Helvetica, sans-serif" size="3">Year
    of Vehicle</font></td>


    <td bgcolor="006600"><font color="CCCCCC" face="Arial, Helvetica, sans-serif" size="3">
    <input name="YearofCar" id="YearofCar2" type="text">
    </font></td>

    </tr>

    <tr>


    <td bgcolor="006600"><font color="CCCCCC" face="Arial, Helvetica, sans-serif" size="3">Extra
    information, if you require a specific part or number of parts enter here</font></td>


    <td bgcolor="006600"><font color="CCCCCC" face="Arial, Helvetica, sans-serif" size="2"> 

    </font><textarea name="PartsRequired" cols="70" id="PartsRequired"></textarea>
    </td>

    </tr>
    <tr>


    <td bgcolor="006600"></td>


    <td bgcolor="006600"><font color="CCCCCC" face="Arial, Helvetica, sans-serif" size="2"> 

    </font><input type="submit" value="SEND">


    </td>

    THIS IS LINE 96 > </tr>



    </tbody>
    </table>

    </form>

    <img style="width: 762px; height: 54px;" alt="" src="images/SummerhillSpares.gif">
    <p> </p>

    <p></p>


    </body>
    </html>


    Thanks in advance...


«1

Comments

  • Registered Users Posts: 21,257 ✭✭✭✭Eoin


    Are you just copying in the source from your browser? That won't be any good as the code that is causing the problem is executed on the server before it is sent to the browser, so line 96 on our browser won't be the line 96 in the ASP page.


  • Registered Users Posts: 3,056 ✭✭✭sticker


    Sorry!

    I'm used to just creating forms in Dreamweaver - not that familiar with ASP code

    What do I do to remedy the problem?

    Heres the ASP code anyway:





    <%@ Language = vbscript%>
    <%option explicit %>
    <%server.scripttimeout = 600 %>
    <%
    '
    FORMMAIL V1.3

    '
    'copyright information
    '
    'Copyright 2002: Sorted Sites http://www.sortedsites.com
    'Authors Jonas Tornqvist, David Parkes and Karl Snares
    'This script is Freeware, which means you are free to use and modify
    'the script for your own use.
    'The only condition is this copyright header remain intact and you don't
    'try and sell this script for profit without first asking us.
    'And of course also ask Matt Wright who wrote the original perl version of Formmail.

    '
    'license agreement - Important
    '
    'By using this script you agree to indeminfy the developers - Sorted Sites of any loss
    'or damages that may arise from its use or missue.
    'This script is provided as is with all faults - no warranties and no guarantees.
    'basically its free - use it at your own risk and cost.
    'No warranties and no tech support - if you need help with this don't ask us!
    'The documentation is provided as is with all the help we can offer.
    'As we develop this script we shall post updates hopefully fix any bugs
    'We are not obliged to release any future versions and we might not bother...
    'By using this script you accept this license agreement!

    '
    'documentation v1.3
    '

    '####################################################################################################
    'this is where the code starts for real
    '####################################################################################################

    '
    'declare variables
    '
    Dim strFrom, strTo, strSubject, strBody
    Dim objMessage, objConfig, strServer, intPort
    Dim recipient, redirect, subject, realname, email, required, strEmail1, strEmail2
    Dim referer, url, url_verified, icounter, query, iloop, query2, query3, i, agree, validation, error0, error0ok

    '############################## CONFIGURATION VARIABLES ####################################

    'These are the only lines you will need to change
    '
    strServer = "mail.summerhillspares.ie" 'set which smtp server will be used to send the email. enter ip address or domain name. eg: "xxx.xxx.xxx.xxx" or "smtp.your-domain.com"
    intPort = 25 'set the smtp port to be used when sending mail (by default port 25 is used)
    'Referrer's Array is defined here. Enter the valid domains which may use this script.
    url = Array("www.summerhillspares.ie","summerhillspares.ie","www.hotmail.com","hotmail.com")'Set which urls that will be accepted. http://xxxxx/
    'Seperate multiple domains by commas
    'eg: url= Array("www.your-domain.com","your-domain.com","www.my-domain.com")
    'computer names can be used instead of domains if this script is being run locally
    'eg: url = Array("computername")

    '######################################### IMPORTANT NOTICE #########################################
    'IMPORTANT: do not modify anything below this line unless you know what you are doing!!
    '######################################### IMPORTANT NOTICE #########################################

    '
    'information type and CDOSYS constants
    '
    %>
    <!--METADATA TYPE="typelib"
    UUID="CD000000-8B95-11D1-82DB-00C04FB1625D"
    NAME="CDO for Windows 2000 Library" -->
    <!--METADATA TYPE="typelib"
    UUID="00000205-0000-0010-8000-00AA006D2EA4"
    NAME="ADODB Type Library" -->
    <%
    '
    'retrieved default fields
    '
    recipient = request("recipient")
    redirect = request("redirect")
    subject = request("subject")
    email = request("email")
    required = request("required")
    if required = "" then
    required = "recipient,subject,email,redirect"
    else
    required = "recipient,subject,email,redirect," & required
    end if

    '
    'verify the referer
    '
    referer = request.ServerVariables("HTTP_REFERER")
    referer = split(referer,"/")
    url_verified = "no"
    for icounter = Lbound(url) to Ubound(url) '
    LINE 96 if referer(2) = url(icounter) then
    url_verified = "yes"
    end if
    next
    if not url_verified = "yes" then
    response.write("The url specified is invalid!")
    response.End
    end if

    '
    'verify the recipient(not tested)
    '
    'trimed_referer = split(referer(2),".")'
    'response.write recipient & "<br>" & referer(2) & "=" & trimed_referer(0) & "<br>"
    'if trimed_referer(0) = "www" then
    ' if InStr(1,recipient,trimed_referer(1),1) = 0 then
    ' response.write "recipient don't match the referer"
    ' response.end
    ' end if
    'else
    ' if InStr(1,recipient,trimed_referer(0),1) = 0 then
    ' response.write "recipient don't match the referer"
    ' response.end
    ' end if
    'end if

    '
    'retrieve form contents and create email fields
    '
    query = Request.ServerVariables("QUERY_STRING")
    query = split(query,"&")
    query3 = split(required,",")
    For iLoop = Lbound(query) to UBound(query)
    query2 = split(query(iloop),"=")

    '
    'form validation, checks required fields are not null
    '
    for i = LBound(query3) to UBound(query3)
    if query3(i) = query2(0) then
    if query2(1) = "" then
    response.write ("you must enter a valid ") & query2(0)
    response.end
    end if
    end if

    'if query2(0) = "agree" then
    'if query2(1) <> "on" or query2(1) = "" then
    ' response.write("You must agree to terms and conditions to enable Formmailv1.3 to execute!")
    'response.end
    'end if
    'end if



    '
    'form validation, checks terms and conditions checkbox has been ticked
    '

    Next
    if not query2(0) = "recipient" and not query2(0) = "redirect" and not query2(0) = "subject" and not query2(0) = "realname" and not query2(0) = "email" and not query2(0) = "required" and not query2(0) = "agree" then
    strBody = strBody & vbnewline & vbnewline & query2(0) &": " & query2(1)
    end if
    Next
    if email = "" then
    email = "formmail@" & referer(2)
    end if
    '
    'replaces any special characters parsed through the query string
    '
    strbody = replace(strbody, "+"," ")
    strbody = replace(strbody, "%26%238364%3B","€")
    strbody = replace(strbody, "%A1","¡")
    strbody = replace(strbody, "%A3","£")
    strbody = replace(strbody, "%A8","¨")
    strbody = replace(strbody, "%AA","ª")
    strbody = replace(strbody, "%AC","¬")
    strbody = replace(strbody, "%B4","´")
    strbody = replace(strbody, "%B7","·")
    strbody = replace(strbody, "%BA","º")
    strbody = replace(strbody, "%BF","¿")
    strbody = replace(strbody, "%C7","Ç")
    strbody = replace(strbody, "%E7","ç")
    strbody = replace(strbody, "%0D%0A",vbnewline)
    strbody = replace(strbody, "%21","!")
    strbody = replace(strbody, "%23","#")
    strbody = replace(strbody, "%24","$")
    strbody = replace(strbody, "%25","%")
    strbody = replace(strbody, "%26","&")
    strbody = replace(strbody, "%27","'")
    strbody = replace(strbody, "%28","(")
    strbody = replace(strbody, "%29",")")
    strbody = replace(strbody, "%2B","+")
    strbody = replace(strbody, "%2C",",")
    strbody = replace(strbody, "%2D","-")
    strbody = replace(strbody, "%2E",".")
    strbody = replace(strbody, "%2F","/")
    strbody = replace(strbody, "%3A",":")
    strbody = replace(strbody, "%3B",";")
    strbody = replace(strbody, "%3C","<")
    strbody = replace(strbody, "%3D","=")
    strbody = replace(strbody, "%3E",">")
    strbody = replace(strbody, "%3F","?")
    strbody = replace(strbody, "%5B","[")
    strbody = replace(strbody, "%5C","\")
    strbody = replace(strbody, "%5D","]")
    strbody = replace(strbody, "%5E","^")
    strbody = replace(strbody, "%5F","_")
    strbody = replace(strbody, "%60","`")
    strbody = replace(strbody, "%7B","{")
    strbody = replace(strbody, "%7C","|")
    strbody = replace(strbody, "%7D","}")
    strbody = replace(strbody, "%7E","~")

    '
    'this creates the body of the mail message, the text in quotes can be modified accordingly
    '
    strBody = "Here is the results of your form submitted from" & referer(2) & vbnewline & vbnewline & "Name: " & realname & vbnewline & vbnewline & "Email: " & email & vbnewline & strBody & vbnewline & vbnewline & "############# End Formmail Tranmission #############"

    '
    'checks if a smtp port has been specified, if not it uses the default port 25
    '
    if intport <> 25 then
    intport = intport
    else
    intport = 25
    end if

    '
    'send the mail message
    '
    set objMessage = CreateObject("CDO.Message")
    objMessage.To = recipient
    objMessage.From = email
    objMessage.Subject = subject
    objMessage.Sender = email
    objMessage.Textbody = strBody

    '
    'cdosys configuration setup
    '
    set objConfig = CreateObject("CDO.Configuration")
    objConfig.Fields(cdoSendUsingMethod) = cdoSendUsingPort
    objConfig.Fields(cdoSMTPServer) = strServer
    objConfig.Fields(cdoSMTPServerPort) = intPort
    objConfig.Fields(cdoSMTPAuthenticate) = cdoAnonymous
    objConfig.Fields.Update
    set objMessage.Configuration = objConfig

    '
    'define error handling procedures
    '
    On Error Resume Next
    objMessage.Send
    If Err.Number = 0 then
    response.write("Formmail v1.3 processed all operations successfully!")
    else
    response.write("Formmail v1.3 detected the following errors:")& "<br>"
    response.write("error no.: ")&err.number & "<br>"
    response.write("description: ")&err.description & "<br>"
    response.end
    End If
    On Error Goto 0

    '
    'send them to the page specified
    '
    Response.Redirect redirect

    '####################################################################################################
    'This is where the code ends
    '####################################################################################################
    %>
    <!-- That's All Folks -->
    <!-- Happy Surfing -->
    <!-- Credits -->
    <!-- David Parkes - Project Planning -->
    <!-- Jonas Tornqvist - Lead Programmer version 1-->
    <!-- Karl Snares - Lead Programmer version 1.2 & 1.3
    <!-- Matt Wright - Original Formmail CGI Developer -->


  • Registered Users Posts: 413 ✭✭ianhobo


    hey,
    The error isnt actually in your code/html, its occuring in the asp page that processes your form.
    /cgi-bin/formmail.asp, line 96
    formmail.asp is causing the error, without seeing that it would be hard to say what the problem is.
    What values did you change in the form and/or html?
    It may be expecting certain values for validation or something else (such as the email address, which maybe you have changed?> So it could be generating the error because of that.

    That formmail.asp is a local file on the webserver, so either check line 96 in that, or post it here so we can have a look


  • Registered Users Posts: 413 ✭✭ianhobo


    the formmail.asp is performing some validation checks.
    Line 96 is run because the 'if' condition is failing. It checks/indexes the array of valid domains at line 54
    Has the website moved domains or changed email addresses/providers?
    What was the old email address?
    And whats the new one?


  • Registered Users Posts: 3,056 ✭✭✭sticker


    ianhobo wrote: »
    hey,
    The error isnt actually in your code/html, its occuring in the asp page that processes your form.

    formmail.asp is causing the error, without seeing that it would be hard to say what the problem is.
    What values did you change in the form and/or html?
    It may be expecting certain values for validation or something else (such as the email address, which maybe you have changed?> So it could be generating the error because of that.

    That formmail.asp is a local file on the webserver, so either check line 96 in that, or post it here so we can have a look

    I've posted the ASP above...

    The only change I made was with the index.htm code - which contains the form html

    I changed the email in this section of code / saved it within Dreamweaver / uploaded it (after removing the old index file)


    <form ACTION="cgi-bin/formmail.asp" method="get" name="form1">
    <input name="recipient" value="info@summerhillspares.ie" type="hidden">
    <input type="hidden" name="redirect" value="http://www.summerhillspares.ie/requestprocessed.htm"&gt;
    <input name="subject" type="hidden" id="subject" value="spare parts request">


  • Advertisement
  • Registered Users Posts: 413 ✭✭ianhobo


    see my replies after what you quoted from me :)


  • Registered Users Posts: 706 ✭✭✭DJB


    Just before line 96 put this in:

    FOR EACH x IN referrer
    thisCount = thisCount + 1
    response.write thisCount & " - " & x & "<br />" & vbcrlf
    NEXT
    response.end

    Post the form again and it should spit out something to the page. Copy and paste that here so I can see it.

    Thanks, Dave


  • Registered Users Posts: 21,257 ✭✭✭✭Eoin


    That error indicates that the code is accessing an index in an array that doesn't exist.

    Off the top of my head, it looks like the code is getting the referring URL, and trying to split it. If you are accessing the page directly, then I'd imagine that the value won't be populated.

    Try something like this - I've not tested it, and it's off the top of my head so may need some tweaking. There's also probably some unnecessary if statements there, but give it a go.
    Dim sRef, avarRef
    sRef = request.ServerVariables("HTTP_REFERER")
    If sRef <> "" Then
        If instr(sRef, "/") > 0 Then
             avarRef = split(sRef, "/")
        End If
    End If
    
    If isArray(avarRef) Then
        If ubound(avarRef) > 1 Then
            for icounter = Lbound(url) to Ubound(url) '
                if avarRef(2) = url(icounter) then
                    url_verified = "yes"
                end if
            next
        End If
    End If
    


  • Registered Users Posts: 706 ✭✭✭DJB


    Alternatively, use a new script... http://www.dynamic.ie/sourcecode/formtomail.asp


  • Registered Users Posts: 3,056 ✭✭✭sticker


    DJB wrote: »
    Just before line 96 put this in:

    FOR EACH x IN referrer
    thisCount = thisCount + 1
    response.write thisCount & " - " & x & "<br />" & vbcrlf
    NEXT
    response.end

    Post the form again and it should spit out something to the page. Copy and paste that here so I can see it.

    Thanks, Dave

    I added the code before line 96 - and uploaded it again - doesn't seem to work

    Still getting this message - I refreshed the new index page before trying...

    Microsoft VBScript runtime error '800a01f4'

    Variable is undefined: 'referrer'

    /cgi-bin/formmail.asp, line 96



    Here's the new ASP code as requested:



    <%@ Language = vbscript%>
    <%option explicit %>
    <%server.scripttimeout = 600 %>
    <%
    '
    FORMMAIL V1.3

    '
    'copyright information
    '
    'Copyright 2002: Sorted Sites http://www.sortedsites.com
    'Authors Jonas Tornqvist, David Parkes and Karl Snares
    'This script is Freeware, which means you are free to use and modify
    'the script for your own use.
    'The only condition is this copyright header remain intact and you don't
    'try and sell this script for profit without first asking us.
    'And of course also ask Matt Wright who wrote the original perl version of Formmail.

    '
    'license agreement - Important
    '
    'By using this script you agree to indeminfy the developers - Sorted Sites of any loss
    'or damages that may arise from its use or missue.
    'This script is provided as is with all faults - no warranties and no guarantees.
    'basically its free - use it at your own risk and cost.
    'No warranties and no tech support - if you need help with this don't ask us!
    'The documentation is provided as is with all the help we can offer.
    'As we develop this script we shall post updates hopefully fix any bugs
    'We are not obliged to release any future versions and we might not bother...
    'By using this script you accept this license agreement!

    '
    'documentation v1.3
    '

    '####################################################################################################
    'this is where the code starts for real
    '####################################################################################################

    '
    'declare variables
    '
    Dim strFrom, strTo, strSubject, strBody
    Dim objMessage, objConfig, strServer, intPort
    Dim recipient, redirect, subject, realname, email, required, strEmail1, strEmail2
    Dim referer, url, url_verified, icounter, query, iloop, query2, query3, i, agree, validation, error0, error0ok

    '############################## CONFIGURATION VARIABLES ####################################

    'These are the only lines you will need to change
    '
    strServer = "mail.summerhillspares.ie" 'set which smtp server will be used to send the email. enter ip address or domain name. eg: "xxx.xxx.xxx.xxx" or "smtp.your-domain.com"
    intPort = 25 'set the smtp port to be used when sending mail (by default port 25 is used)
    'Referrer's Array is defined here. Enter the valid domains which may use this script.
    url = Array("www.summerhillspares.ie","summerhillspares.ie","www.hotmail.com","hotmail.com")'Set which urls that will be accepted. http://xxxxx/
    'Seperate multiple domains by commas
    'eg: url= Array("www.your-domain.com","your-domain.com","www.my-domain.com")
    'computer names can be used instead of domains if this script is being run locally
    'eg: url = Array("computername")

    '######################################### IMPORTANT NOTICE #########################################
    'IMPORTANT: do not modify anything below this line unless you know what you are doing!!
    '######################################### IMPORTANT NOTICE #########################################

    '
    'information type and CDOSYS constants
    '
    %>
    <!--METADATA TYPE="typelib"
    UUID="CD000000-8B95-11D1-82DB-00C04FB1625D"
    NAME="CDO for Windows 2000 Library" -->
    <!--METADATA TYPE="typelib"
    UUID="00000205-0000-0010-8000-00AA006D2EA4"
    NAME="ADODB Type Library" -->
    <%
    '
    'retrieved default fields
    '
    recipient = request("recipient")
    redirect = request("redirect")
    subject = request("subject")
    email = request("email")
    required = request("required")
    if required = "" then
    required = "recipient,subject,email,redirect"
    else
    required = "recipient,subject,email,redirect," & required
    end if

    '
    'verify the referer
    '
    referer = request.ServerVariables("HTTP_REFERER")
    referer = split(referer,"/")
    url_verified = "no"
    for icounter = Lbound(url) to Ubound(url) '
    FOR EACH x IN referrer
    thisCount = thisCount + 1
    response.write thisCount & " - " & x & "<br />" & vbcrlf
    NEXT
    response.end
    if referer(2) = url(icounter) then
    url_verified = "yes"
    end if
    next
    if not url_verified = "yes" then
    response.write("The url specified is invalid!")
    response.End
    end if

    '
    'verify the recipient(not tested)
    '
    'trimed_referer = split(referer(2),".")'
    'response.write recipient & "<br>" & referer(2) & "=" & trimed_referer(0) & "<br>"
    'if trimed_referer(0) = "www" then
    ' if InStr(1,recipient,trimed_referer(1),1) = 0 then
    ' response.write "recipient don't match the referer"
    ' response.end
    ' end if
    'else
    ' if InStr(1,recipient,trimed_referer(0),1) = 0 then
    ' response.write "recipient don't match the referer"
    ' response.end
    ' end if
    'end if

    '
    'retrieve form contents and create email fields
    '
    query = Request.ServerVariables("QUERY_STRING")
    query = split(query,"&")
    query3 = split(required,",")
    For iLoop = Lbound(query) to UBound(query)
    query2 = split(query(iloop),"=")

    '
    'form validation, checks required fields are not null
    '
    for i = LBound(query3) to UBound(query3)
    if query3(i) = query2(0) then
    if query2(1) = "" then
    response.write ("you must enter a valid ") & query2(0)
    response.end
    end if
    end if

    'if query2(0) = "agree" then
    'if query2(1) <> "on" or query2(1) = "" then
    ' response.write("You must agree to terms and conditions to enable Formmailv1.3 to execute!")
    'response.end
    'end if
    'end if



    '
    'form validation, checks terms and conditions checkbox has been ticked
    '

    Next
    if not query2(0) = "recipient" and not query2(0) = "redirect" and not query2(0) = "subject" and not query2(0) = "realname" and not query2(0) = "email" and not query2(0) = "required" and not query2(0) = "agree" then
    strBody = strBody & vbnewline & vbnewline & query2(0) &": " & query2(1)
    end if
    Next
    if email = "" then
    email = "formmail@" & referer(2)
    end if
    '
    'replaces any special characters parsed through the query string
    '
    strbody = replace(strbody, "+"," ")
    strbody = replace(strbody, "%26%238364%3B","€")
    strbody = replace(strbody, "%A1","¡")
    strbody = replace(strbody, "%A3","£")
    strbody = replace(strbody, "%A8","¨")
    strbody = replace(strbody, "%AA","ª")
    strbody = replace(strbody, "%AC","¬")
    strbody = replace(strbody, "%B4","´")
    strbody = replace(strbody, "%B7","·")
    strbody = replace(strbody, "%BA","º")
    strbody = replace(strbody, "%BF","¿")
    strbody = replace(strbody, "%C7","Ç")
    strbody = replace(strbody, "%E7","ç")
    strbody = replace(strbody, "%0D%0A",vbnewline)
    strbody = replace(strbody, "%21","!")
    strbody = replace(strbody, "%23","#")
    strbody = replace(strbody, "%24","$")
    strbody = replace(strbody, "%25","%")
    strbody = replace(strbody, "%26","&")
    strbody = replace(strbody, "%27","'")
    strbody = replace(strbody, "%28","(")
    strbody = replace(strbody, "%29",")")
    strbody = replace(strbody, "%2B","+")
    strbody = replace(strbody, "%2C",",")
    strbody = replace(strbody, "%2D","-")
    strbody = replace(strbody, "%2E",".")
    strbody = replace(strbody, "%2F","/")
    strbody = replace(strbody, "%3A",":")
    strbody = replace(strbody, "%3B",";")
    strbody = replace(strbody, "%3C","<")
    strbody = replace(strbody, "%3D","=")
    strbody = replace(strbody, "%3E",">")
    strbody = replace(strbody, "%3F","?")
    strbody = replace(strbody, "%5B","[")
    strbody = replace(strbody, "%5C","\")
    strbody = replace(strbody, "%5D","]")
    strbody = replace(strbody, "%5E","^")
    strbody = replace(strbody, "%5F","_")
    strbody = replace(strbody, "%60","`")
    strbody = replace(strbody, "%7B","{")
    strbody = replace(strbody, "%7C","|")
    strbody = replace(strbody, "%7D","}")
    strbody = replace(strbody, "%7E","~")

    '
    'this creates the body of the mail message, the text in quotes can be modified accordingly
    '
    strBody = "Here is the results of your form submitted from" & referer(2) & vbnewline & vbnewline & "Name: " & realname & vbnewline & vbnewline & "Email: " & email & vbnewline & strBody & vbnewline & vbnewline & "############# End Formmail Tranmission #############"

    '
    'checks if a smtp port has been specified, if not it uses the default port 25
    '
    if intport <> 25 then
    intport = intport
    else
    intport = 25
    end if

    '
    'send the mail message
    '
    set objMessage = CreateObject("CDO.Message")
    objMessage.To = recipient
    objMessage.From = email
    objMessage.Subject = subject
    objMessage.Sender = email
    objMessage.Textbody = strBody

    '
    'cdosys configuration setup
    '
    set objConfig = CreateObject("CDO.Configuration")
    objConfig.Fields(cdoSendUsingMethod) = cdoSendUsingPort
    objConfig.Fields(cdoSMTPServer) = strServer
    objConfig.Fields(cdoSMTPServerPort) = intPort
    objConfig.Fields(cdoSMTPAuthenticate) = cdoAnonymous
    objConfig.Fields.Update
    set objMessage.Configuration = objConfig

    '
    'define error handling procedures
    '
    On Error Resume Next
    objMessage.Send
    If Err.Number = 0 then
    response.write("Formmail v1.3 processed all operations successfully!")
    else
    response.write("Formmail v1.3 detected the following errors:")& "<br>"
    response.write("error no.: ")&err.number & "<br>"
    response.write("description: ")&err.description & "<br>"
    response.end
    End If
    On Error Goto 0

    '
    'send them to the page specified
    '
    Response.Redirect redirect

    '####################################################################################################
    'This is where the code ends
    '####################################################################################################
    %>
    <!-- That's All Folks -->
    <!-- Happy Surfing -->
    <!-- Credits -->
    <!-- David Parkes - Project Planning -->
    <!-- Jonas Tornqvist - Lead Programmer version 1-->
    <!-- Karl Snares - Lead Programmer version 1.2 & 1.3
    <!-- Matt Wright - Original Formmail CGI Developer -->


  • Advertisement
  • Registered Users Posts: 3,056 ✭✭✭sticker


    DJB wrote: »
    Alternatively, use a new script... http://www.dynamic.ie/sourcecode/formtomail.asp


    Do I just overwrite the old asp code with the code provided in the link you posted and then upload it?

    Sorry everyone - I'm just not familiar with ASP coding!


  • Registered Users Posts: 3,056 ✭✭✭sticker


    eoin_s wrote: »
    That error indicates that the code is accessing an index in an array that doesn't exist.

    Off the top of my head, it looks like the code is getting the referring URL, and trying to split it. If you are accessing the page directly, then I'd imagine that the value won't be populated.

    Try something like this - I've not tested it, and it's off the top of my head so may need some tweaking. There's also probably some unnecessary if statements there, but give it a go.
    Dim sRef, avarRef
    sRef = request.ServerVariables("HTTP_REFERER")
    If sRef <> "" Then
        If instr(sRef, "/") > 0 Then
             avarRef = split(sRef, "/")
        End If
    End If
    
    If isArray(avarRef) Then
        If ubound(avarRef) > 1 Then
            for icounter = Lbound(url) to Ubound(url) '
                if avarRef(2) = url(icounter) then
                    url_verified = "yes"
                end if
            next
        End If
    End If
    

    Thanks Eoin -

    I'm fortunate to have a LOT of replies here today!

    Where do I place this code? in the ASP / index ? / at which line etc?!


  • Registered Users Posts: 413 ✭✭ianhobo


    the entries in the url array on line 54 are not mathcing up with the referer which is whats being checked in line 96 .What is your refererer??
    Again i ask you, has the website moved domains? because this would change the referer object


  • Registered Users Posts: 706 ✭✭✭DJB


    for new script, follow instructions that come with it.

    In code piece I asked you to put in, change referrer to referer wherever you see it. I spelt it wrong!


  • Registered Users Posts: 21,257 ✭✭✭✭Eoin


    Maybe I'm just not tuned in today, but does that code only allow the mail to be sent when the HTTP_REFERER is from a certain domain? So, if someone goes to that page from any other site (or directly without clicking a link to it), then it won't work?

    Unless you've got a massive spam problem, it seems a little OTT.

    By the way, that code I posted should work as is.


  • Registered Users Posts: 706 ✭✭✭DJB


    ianhobo... I agree, I just looked at the script more.

    He said, that's the old site. What's the new one?


  • Registered Users Posts: 21,257 ✭✭✭✭Eoin


    sticker wrote: »
    Thanks Eoin -

    I'm fortunate to have a LOT of replies here today!

    Where do I place this code? in the ASP / index ? / at which line etc?!

    That should replace lines 92 to 99 in formmail.asp


  • Registered Users Posts: 3,056 ✭✭✭sticker


    ianhobo wrote: »
    the entries in the url array on line 54 are not mathcing up with the referer which is whats being checked in line 96 .What is your refererer??
    Again i ask you, has the website moved domains? because this would change the referer object

    Sorry - What do you mean "referer" it's hosted by 365 domains... the website hasn't changed domains since I've been asked to help...

    I assumed it would be a simple change of html code!

    The only change I made was to the html code - changing the email value - then this error appeared!


  • Registered Users Posts: 3,056 ✭✭✭sticker


    eoin_s wrote: »
    That should replace lines 92 to 99 in formmail.asp

    Code reads like this Eoin - is this correct?

    <%@ Language = vbscript%>
    <%option explicit %>
    <%server.scripttimeout = 600 %>
    <%
    '
    FORMMAIL V1.3

    '
    'copyright information
    '
    'Copyright 2002: Sorted Sites http://www.sortedsites.com
    'Authors Jonas Tornqvist, David Parkes and Karl Snares
    'This script is Freeware, which means you are free to use and modify
    'the script for your own use.
    'The only condition is this copyright header remain intact and you don't
    'try and sell this script for profit without first asking us.
    'And of course also ask Matt Wright who wrote the original perl version of Formmail.

    '
    'license agreement - Important
    '
    'By using this script you agree to indeminfy the developers - Sorted Sites of any loss
    'or damages that may arise from its use or missue.
    'This script is provided as is with all faults - no warranties and no guarantees.
    'basically its free - use it at your own risk and cost.
    'No warranties and no tech support - if you need help with this don't ask us!
    'The documentation is provided as is with all the help we can offer.
    'As we develop this script we shall post updates hopefully fix any bugs
    'We are not obliged to release any future versions and we might not bother...
    'By using this script you accept this license agreement!

    '
    'documentation v1.3
    '

    '####################################################################################################
    'this is where the code starts for real
    '####################################################################################################

    '
    'declare variables
    '
    Dim strFrom, strTo, strSubject, strBody
    Dim objMessage, objConfig, strServer, intPort
    Dim recipient, redirect, subject, realname, email, required, strEmail1, strEmail2
    Dim referer, url, url_verified, icounter, query, iloop, query2, query3, i, agree, validation, error0, error0ok

    '############################## CONFIGURATION VARIABLES ####################################

    'These are the only lines you will need to change
    '
    strServer = "mail.summerhillspares.ie" 'set which smtp server will be used to send the email. enter ip address or domain name. eg: "xxx.xxx.xxx.xxx" or "smtp.your-domain.com"
    intPort = 25 'set the smtp port to be used when sending mail (by default port 25 is used)
    'Referrer's Array is defined here. Enter the valid domains which may use this script.
    url = Array("www.summerhillspares.ie","summerhillspares.ie","www.hotmail.com","hotmail.com")'Set which urls that will be accepted. http://xxxxx/
    'Seperate multiple domains by commas
    'eg: url= Array("www.your-domain.com","your-domain.com","www.my-domain.com")
    'computer names can be used instead of domains if this script is being run locally
    'eg: url = Array("computername")

    '######################################### IMPORTANT NOTICE #########################################
    'IMPORTANT: do not modify anything below this line unless you know what you are doing!!
    '######################################### IMPORTANT NOTICE #########################################

    '
    'information type and CDOSYS constants
    '
    %>
    <!--METADATA TYPE="typelib"
    UUID="CD000000-8B95-11D1-82DB-00C04FB1625D"
    NAME="CDO for Windows 2000 Library" -->
    <!--METADATA TYPE="typelib"
    UUID="00000205-0000-0010-8000-00AA006D2EA4"
    NAME="ADODB Type Library" -->
    <%
    '
    'retrieved default fields
    '
    recipient = request("recipient")
    redirect = request("redirect")
    subject = request("subject")
    email = request("email")
    required = request("required")
    if required = "" then
    required = "recipient,subject,email,redirect"
    else
    required = "recipient,subject,email,redirect," & required
    end if

    '
    'verify the referer
    '
    Dim sRef, avarRef
    sRef = request.ServerVariables("HTTP_REFERER")
    If sRef <> "" Then
    If instr(sRef, "/") > 0 Then
    avarRef = split(sRef, "/")
    End If
    End If

    If isArray(avarRef) Then
    If ubound(avarRef) > 1 Then
    for icounter = Lbound(url) to Ubound(url) '
    if avarRef(2) = url(icounter) then
    url_verified = "yes"
    end if
    next
    End If
    End If
    next
    if not url_verified = "yes" then
    response.write("The url specified is invalid!")
    response.End
    end if

    '
    'verify the recipient(not tested)
    '
    'trimed_referer = split(referer(2),".")'
    'response.write recipient & "<br>" & referer(2) & "=" & trimed_referer(0) & "<br>"
    'if trimed_referer(0) = "www" then
    ' if InStr(1,recipient,trimed_referer(1),1) = 0 then
    ' response.write "recipient don't match the referer"
    ' response.end
    ' end if
    'else
    ' if InStr(1,recipient,trimed_referer(0),1) = 0 then
    ' response.write "recipient don't match the referer"
    ' response.end
    ' end if
    'end if

    '
    'retrieve form contents and create email fields
    '
    query = Request.ServerVariables("QUERY_STRING")
    query = split(query,"&")
    query3 = split(required,",")
    For iLoop = Lbound(query) to UBound(query)
    query2 = split(query(iloop),"=")

    '
    'form validation, checks required fields are not null
    '
    for i = LBound(query3) to UBound(query3)
    if query3(i) = query2(0) then
    if query2(1) = "" then
    response.write ("you must enter a valid ") & query2(0)
    response.end
    end if
    end if

    'if query2(0) = "agree" then
    'if query2(1) <> "on" or query2(1) = "" then
    ' response.write("You must agree to terms and conditions to enable Formmailv1.3 to execute!")
    'response.end
    'end if
    'end if



    '
    'form validation, checks terms and conditions checkbox has been ticked
    '

    Next
    if not query2(0) = "recipient" and not query2(0) = "redirect" and not query2(0) = "subject" and not query2(0) = "realname" and not query2(0) = "email" and not query2(0) = "required" and not query2(0) = "agree" then
    strBody = strBody & vbnewline & vbnewline & query2(0) &": " & query2(1)
    end if
    Next
    if email = "" then
    email = "formmail@" & referer(2)
    end if
    '
    'replaces any special characters parsed through the query string
    '
    strbody = replace(strbody, "+"," ")
    strbody = replace(strbody, "%26%238364%3B","€")
    strbody = replace(strbody, "%A1","¡")
    strbody = replace(strbody, "%A3","£")
    strbody = replace(strbody, "%A8","¨")
    strbody = replace(strbody, "%AA","ª")
    strbody = replace(strbody, "%AC","¬")
    strbody = replace(strbody, "%B4","´")
    strbody = replace(strbody, "%B7","·")
    strbody = replace(strbody, "%BA","º")
    strbody = replace(strbody, "%BF","¿")
    strbody = replace(strbody, "%C7","Ç")
    strbody = replace(strbody, "%E7","ç")
    strbody = replace(strbody, "%0D%0A",vbnewline)
    strbody = replace(strbody, "%21","!")
    strbody = replace(strbody, "%23","#")
    strbody = replace(strbody, "%24","$")
    strbody = replace(strbody, "%25","%")
    strbody = replace(strbody, "%26","&")
    strbody = replace(strbody, "%27","'")
    strbody = replace(strbody, "%28","(")
    strbody = replace(strbody, "%29",")")
    strbody = replace(strbody, "%2B","+")
    strbody = replace(strbody, "%2C",",")
    strbody = replace(strbody, "%2D","-")
    strbody = replace(strbody, "%2E",".")
    strbody = replace(strbody, "%2F","/")
    strbody = replace(strbody, "%3A",":")
    strbody = replace(strbody, "%3B",";")
    strbody = replace(strbody, "%3C","<")
    strbody = replace(strbody, "%3D","=")
    strbody = replace(strbody, "%3E",">")
    strbody = replace(strbody, "%3F","?")
    strbody = replace(strbody, "%5B","[")
    strbody = replace(strbody, "%5C","\")
    strbody = replace(strbody, "%5D","]")
    strbody = replace(strbody, "%5E","^")
    strbody = replace(strbody, "%5F","_")
    strbody = replace(strbody, "%60","`")
    strbody = replace(strbody, "%7B","{")
    strbody = replace(strbody, "%7C","|")
    strbody = replace(strbody, "%7D","}")
    strbody = replace(strbody, "%7E","~")

    '
    'this creates the body of the mail message, the text in quotes can be modified accordingly
    '
    strBody = "Here is the results of your form submitted from" & referer(2) & vbnewline & vbnewline & "Name: " & realname & vbnewline & vbnewline & "Email: " & email & vbnewline & strBody & vbnewline & vbnewline & "############# End Formmail Tranmission #############"

    '
    'checks if a smtp port has been specified, if not it uses the default port 25
    '
    if intport <> 25 then
    intport = intport
    else
    intport = 25
    end if

    '
    'send the mail message
    '
    set objMessage = CreateObject("CDO.Message")
    objMessage.To = recipient
    objMessage.From = email
    objMessage.Subject = subject
    objMessage.Sender = email
    objMessage.Textbody = strBody

    '
    'cdosys configuration setup
    '
    set objConfig = CreateObject("CDO.Configuration")
    objConfig.Fields(cdoSendUsingMethod) = cdoSendUsingPort
    objConfig.Fields(cdoSMTPServer) = strServer
    objConfig.Fields(cdoSMTPServerPort) = intPort
    objConfig.Fields(cdoSMTPAuthenticate) = cdoAnonymous
    objConfig.Fields.Update
    set objMessage.Configuration = objConfig

    '
    'define error handling procedures
    '
    On Error Resume Next
    objMessage.Send
    If Err.Number = 0 then
    response.write("Formmail v1.3 processed all operations successfully!")
    else
    response.write("Formmail v1.3 detected the following errors:")& "<br>"
    response.write("error no.: ")&err.number & "<br>"
    response.write("description: ")&err.description & "<br>"
    response.end
    End If
    On Error Goto 0

    '
    'send them to the page specified
    '
    Response.Redirect redirect

    '####################################################################################################
    'This is where the code ends
    '####################################################################################################
    %>
    <!-- That's All Folks -->
    <!-- Happy Surfing -->
    <!-- Credits -->
    <!-- David Parkes - Project Planning -->
    <!-- Jonas Tornqvist - Lead Programmer version 1-->
    <!-- Karl Snares - Lead Programmer version 1.2 & 1.3
    <!-- Matt Wright - Original Formmail CGI Developer -->


  • Registered Users Posts: 706 ✭✭✭DJB


    Give me ftp access and i'll have it working in 2 mins! :D


  • Advertisement
  • Registered Users Posts: 3,056 ✭✭✭sticker


    DJB wrote: »
    ianhobo... I agree, I just looked at the script more.

    He said, that's the old site. What's the new one?

    I'm building a simple alternative site for him - it's not online yet...

    I thought I had a simple task this morning of changing the email attribute in the form (which was part of the existing site)


  • Registered Users Posts: 21,257 ✭✭✭✭Eoin


    No, 92 - 99 inclusive, there's an extra "next" there that needs removing. Or DJB can sort you out - I would, but I've no FTP access at work.
    '----------------------------------------------------------------------------------------------------
    'verify the referer
    '----------------------------------------------------------------------------------------------------
    Dim sRef, avarRef
    sRef = request.ServerVariables("HTTP_REFERER")
    If sRef <> "" Then
    	If instr(sRef, "/") > 0 Then
    		avarRef = split(sRef, "/")
    	End If
    End If
    
    If isArray(avarRef) Then
    	If ubound(avarRef) > 1 Then
    		for icounter = Lbound(url) to Ubound(url) '
    			if avarRef(2) = url(icounter) then
    				url_verified = "yes"
    			end if
    		next
    	End If
    End If
    
    if not url_verified = "yes" then
    	response.write("The url specified is invalid!")
    	response.End
    end if
    
    '----------------------------------------------------------------------------------------------------
    'verify the recipient(not tested)
    '----------------------------------------------------------------------------------------------------
    
    


  • Registered Users Posts: 3,056 ✭✭✭sticker


    DJB wrote: »
    Give me ftp access and i'll have it working in 2 mins! :D


    PM sent DJB - Much appreciated!!


  • Registered Users Posts: 413 ✭✭ianhobo


    ok, i missed a few replies
    The referer, or HTTP referer, identifies, from the point of view of an internet webpage or resource, the address of the webpage (commonly the URL, the more generic URI or the i18n updated IRI) of the resource which links to it. By checking the referer, the new page can see where the request came from.

    addthe domain of where ever your test stuff is hosted to into the array at line 54. e.g www.hosting365.com or whatever it is
    This WONT work is your running on localhost (your own machine)
    (if you add localhost/127.0.0.1 to the array too, line 96 error shouldn't occur, but no mail will be sent)
    Howd you get on DJB?


  • Registered Users Posts: 3,056 ✭✭✭sticker


    DJB is on the case!

    Thanks so much to everyone who helped today! ;)


  • Registered Users Posts: 3,056 ✭✭✭sticker


    ianhobo wrote: »
    ok, i missed a few replies



    addthe domain of where ever your test stuff is hosted to into the array at line 54. e.g www.hosting365.com or whatever it is
    This WONT work is your running on localhost (your own machine)
    (if you add localhost/127.0.0.1 to the array too, line 96 error shouldn't occur, but no mail will be sent)
    Howd you get on DJB?

    He has the FTP codes -

    It's a bit spooky that this amount of work is needed to change a simple thing!

    I know my way around html but I need a crash course in ASP methinks!

    I'll be changing the aesthetic look of the site down the road,

    If I alter the colour scheme / fonts of the html file (where the form is) will I need to go through this again?!!

    Thanks


  • Registered Users Posts: 413 ✭✭ianhobo


    its not that much work really, if you know asp.

    but before you go diving in, asp is quite general.
    it can (in general) be written in one of MANY languages, your stuff here is in VBScript and would be called "classic asp"
    You can also write it in JSript

    The newer asp stuff is the dot net. This can be written in c#,j#,jscript net, vb, managed cpp, cobol, yada yada yada.

    if your only starting, sure you may as well start out by learning one of the newer languages? try c#, or i think jscript.net is a bit easier going and more resembles the old "classic asp"

    or check out php! ( i should really do that myself....... :) )


  • Registered Users Posts: 21,257 ✭✭✭✭Eoin


    sticker wrote: »
    He has the FTP codes -

    It's a bit spooky that this amount of work is needed to change a simple thing!

    I know my way around html but I need a crash course in ASP methinks!

    I'll be changing the aesthetic look of the site down the road,

    If I alter the colour scheme / fonts of the html file (where the form is) will I need to go through this again?!!

    Thanks

    It seems to be more of a case of overly complicated code


  • Registered Users Posts: 3,056 ✭✭✭sticker


    eoin_s wrote: »
    It seems to be more of a case of overly complicated code

    good to know it wasn't just me being an absolute dumbell!


  • Advertisement
  • Registered Users Posts: 706 ✭✭✭DJB


    Lads, strange problem. I found where it is happening but don't know why!

    line 92 - referer = request.ServerVariables("HTTP_REFERER")

    On the OP machine, when he visits the site and clicks send, for some reason, referer is blank, which in turn breaks the array call. But on my machine, it is what it should be, i.e. http://www.summerhillspares.ie/

    I've done a response.write just after this line so could you guys go to the site, click the send button and tell me if it comes back with a blank page or has "http://www.summerhillspares.ie/".

    This might be local to the OP's machine but how can this happen as this is all happening on the server. Why can't request.ServerVariables("HTTP_REFERER") not read the OP's previous page?

    Not seen this before!


Advertisement