如果在ASP中CAPTCHA为真,如何处理表单

时间:2014-03-09 18:47:14

标签: forms asp-classic captcha

我几乎让CAPTCHA系统在这个特定网站上运行。我使用了http://www.tipstricks.org中的验证码表单。一切似乎都在起作用,但是当我填写联系表格时,价值不会通过电子邮件提交。我只是从缺少的所有值中获得联系。我不确定如何传递表单中的值,以便它包含在电子邮件中。以下是此特定asp页面上的代码:

<form name="form1" id="form1" method="post" action="send_email.asp" value="<%
                        If Session("form1") <> "" Then Response.Write(Session("form1"))%>" />
                        <table border="0" align="center" cellpadding="2" cellspacing="0">
                        <tr> 
                        <td>Contact Name</td>
                        <td width="20" align="center">:</td>
                        <td><input name="name" type="text" id="name" size="30"></td>
                        </tr>
                        <tr> 
                        <td>E-mail Address</td>
                        <td align="center">:</td>
                        <td><input name="email" type="text" id="email" size="30"></td>
                        </tr>
                        <tr> 
                        <td>Comments</td>
                        <td align="center">:</td>
                        <td><input name="comments" type="text" id="comments" size="30"></td>
                        </tr>
                        <tr> 
                        <td>&nbsp;</td>
                        <td align="center">&nbsp;</td>


                        </tr>
                        </table>




                        <div style="text-align: center; margin-top: 20px;">
                            <%
                            if Request.ServerVariables("REQUEST_METHOD") = "POST" and IsEmpty(Request.Form("btnRetry")) then
                                Dim lblResult, lblColor
                                if IsEmpty(Session("ASPCAPTCHA")) or Trim(Session("ASPCAPTCHA")) = "" then
                                    lblResult = "This test has expired."
                                    lblColor = "red"
                                else
                                    Dim TestValue : TestValue = Trim(Request.Form("txtCaptcha"))
                                    '//Uppercase fix for turkish charset//
                                    TestValue = Replace(TestValue, "i", "I", 1, -1, 1)
                                    TestValue = Replace(TestValue, "İ", "I", 1, -1, 1)
                                    TestValue = Replace(TestValue, "ı", "I", 1, -1, 1)
                                    '////////////////////
                                    TestValue = UCase(TestValue)

                                    if StrComp(TestValue, Trim(Session("ASPCAPTCHA")), 1) = 0 then
                                        lblResult = "CAPTCHA PASSED"
                                        lblColor = "green"
                                        Session("form1") = Request.Form("form1")
                                            response.redirect "send_email.asp"
                                    else
                                        lblResult = "CAPTCHA FAILED"
                                        lblColor = "red"
                                    end if
                                    '//IMPORTANT: You must remove session value for security after the CAPTCHA test//
                                    Session("ASPCAPTCHA") = vbNullString
                                    Session.Contents.Remove("ASPCAPTCHA")
                                    '////////////////////
                                end if
                            %>
                            <p><span style="color: <%=lblColor%>; font-weight: bold;"><%=lblResult%></span></p>
                            <input type="submit" name="btnRetry" id="btnRetry" value="Take another test" />
                            <%else%>
                            <img src="captcha.asp" id="imgCaptcha" />&nbsp;<a href="javascript:void(0);" onclick="RefreshImage('imgCaptcha');">Get a new challenge</a><br />
                            Write the characters in the image above<br />
                            <input type="text" name="txtCaptcha" id="txtCaptcha" value="" /><br />
                            <input type="submit" name="btnSubmit" id="btnSubmit" value="Submit" />
                            <%end if%>

                        </form>

非常感谢任何帮助。

0 个答案:

没有答案