Solved

Want to run Captcha on only one of my two action button

Posted on 2012-03-13
8
288 Views
Last Modified: 2012-03-14
I have a Captcha installed on my "Subcribe to Mailing List" form that runs well. The only thing is that I also have a "Unsubscribe" button on the same form and it also calls the same Captcha. How can I have the Captcha to run only on the "Subscribe" button and not the "Unsubscribe"?
The CAPTCHA comes from a Dreamweaver Plug-in
http://www.hotdreamweaver.com/form-captcha


Thank you.
0
Comment
Question by:Comptrib
8 Comments
 
LVL 52

Accepted Solution

by:
Scott Fell,  EE MVE earned 500 total points
ID: 37714550
If you don't feel comfortable with coding and only using dreamweaver wysiwyg, then just create a separate form for unsubscribe without the captcha.  Otherwise, if you are using asp, look for where the form gets processed and bypass the captcha look up on submit if that button is pressed.
0
 
LVL 19

Expert Comment

by:Bardobrave
ID: 37714565
It should be easy enough, although without any code insight...

Your form have two buttons, and I supose that both execute different actions. You must isolate the point where you call the captcha and make that it doesn't execute when action from unsubscribe button is called.

If the captcha is launched on the form onsubmit event you should detect on client code wich button has been clicked before submitting and cancel the captcha execution.
0
 
LVL 18

Expert Comment

by:nap0leon
ID: 37714774
If you are using HTML "buttons", e.g.,
	<input type="text" name="captcha" value="default"/>
	<button name="subscribe" value="1" />Subscribe</button>
	<button name="unsubscribe"  value="1" />Unsubscribe</button>

Open in new window


The form post above will pass either:
1- captcha=default and subscribe=1
or
1- captcha=default and unsubscribe=1

So you can use whatever the appropriate server-side code for detecting the form post value to see if
Request("subscribe") = "1"
or
Request("unsubscribe") = "1"
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Comptrib
ID: 37714865
The two buttons are calling the same function with a Value of "0" or "1". I'm just not sure of what to write to bypass the Captcha if the value is "0".

Here's the code;

<div class="indent1"><input type="button" id="Subscribe" name="Subscribe" value="Subscribe" onClick="javascript:submitForm(this.form, 1)" />
</div>
<br />
<p class="indentReduceText"><em>Fields marked with ** are required.</em></p>
<hr />
<p>If you are a subscriber and wish to be removed from our <em>Mailing List</em>, please enter your<br />
  e-mail address and click on the <strong>Unsubscribe</strong> button.</p>
<div class="indent1">
  <div class="reducetext">
    <label for="unsubscribeEmail">E-mail Address:</label>
  </div>
</div>
<input name="email2" id="unsubscribeEmail" type="text" size="30" maxlength="125" />
<br />
<div class="indent1">
  <input type="submit" id="Unsubscribe" name="Unsubscribe" value="Unsubscribe" onClick="javascript:submitForm(this.form, 0)" />
</div>
<input type="hidden" name="hdwfail" id="hdwfail" value="MailingList-eng.asp?hdwmsg=invalid" />
        </form>
0
 
LVL 18

Expert Comment

by:nap0leon
ID: 37715060
Can you post the "function submitForm()"
Is there are server-side code that verifies the captcha or is it all client-side?
0
 

Author Comment

by:Comptrib
ID: 37715260
This is the code;

<script language=vbscript runat=server>
Sub HDWCaptchaValidation
If (Request.QueryString("hdwtest") = "captchainstalled") Then
  Response.Write "Captcha verification code installed."
  Response.End
End If
If (UCase(Request.ServerVariables("REQUEST_METHOD")) = "POST") OR (Request.QueryString.Count >= 4) Then
    Dim SessionCAPTCHA, CheckCAPTCHA, HDWCaptchaBack, HDWname
      SessionCAPTCHA = Trim(CStr(Session("HDWCAPTCHA")))
      Session("CAPTCHA") = ""
      HDWCaptchaBack = Request.Form("hdwfail")      
      If (HDWCaptchaBack = "") Then HDWCaptchaBack = Request.QueryString("hdwfail")
    For Each HDWname in Request.QueryString
        Response.Cookies("hdw" & HDWname) = Request.QueryString(HDWname)
    Next
    For Each HDWname in Request.Form
        Response.Cookies("hdw" & HDWname) = Request.Form(HDWname)
    Next
    For Each HDWname in Request.Cookies
        On Error Resume Next
        If (Left(HDWname,3) = "hdw") AND (Request.QueryString(Right(HDWname,Len(HDWname)-3)) = "") AND (Request.Form(Right(HDWname,Len(HDWname)-3)) = "") Then
             If (Err.Description = "") Then Response.Cookies(HDWname) = ""
        End If  
    Next      
      If (Len(SessionCAPTCHA) < 1) OR ((Request.Form("hdcaptcha") = "") AND (Request.QueryString("hdcaptcha") = "")) OR ((SessionCAPTCHA <> CStr(Request.Form("hdcaptcha"))) AND (SessionCAPTCHA <> CStr(Request.QueryString("hdcaptcha")))) Then
     Response.Redirect HDWCaptchaBack
     Response.End
 End If
 For Each HDWname in Request.Cookies
     If (Left(HDWname,3) = "hdw") Then
         Response.Cookies(HDWname) = ""
     End If
 Next
End If
End Sub
</script>
<% HDWCaptchaValidation %><script language=vbscript runat=server>
Sub HDWCaptchaValidation
If (Request.QueryString("hdwtest") = "captchainstalled") Then
  Response.Write "Captcha verification code installed."
  Response.End
End If
If (UCase(Request.ServerVariables("REQUEST_METHOD")) = "POST") OR (Request.QueryString.Count >= 4) Then
    Dim SessionCAPTCHA, CheckCAPTCHA, HDWCaptchaBack, HDWname
      SessionCAPTCHA = Trim(CStr(Session("HDWCAPTCHA")))
      Session("CAPTCHA") = ""
      HDWCaptchaBack = Request.Form("hdwfail")      
      If (HDWCaptchaBack = "") Then HDWCaptchaBack = Request.QueryString("hdwfail")
    For Each HDWname in Request.QueryString
        Response.Cookies("hdw" & HDWname) = Request.QueryString(HDWname)
    Next
    For Each HDWname in Request.Form
        Response.Cookies("hdw" & HDWname) = Request.Form(HDWname)
    Next
    For Each HDWname in Request.Cookies
        On Error Resume Next
        If (Left(HDWname,3) = "hdw") AND (Request.QueryString(Right(HDWname,Len(HDWname)-3)) = "") AND (Request.Form(Right(HDWname,Len(HDWname)-3)) = "") Then
             If (Err.Description = "") Then Response.Cookies(HDWname) = ""
        End If  
    Next      
      If (Len(SessionCAPTCHA) < 1) OR ((Request.Form("hdcaptcha") = "") AND (Request.QueryString("hdcaptcha") = "")) OR ((SessionCAPTCHA <> CStr(Request.Form("hdcaptcha"))) AND (SessionCAPTCHA <> CStr(Request.QueryString("hdcaptcha")))) Then
     Response.Redirect HDWCaptchaBack
     Response.End
 End If
 For Each HDWname in Request.Cookies
     If (Left(HDWname,3) = "hdw") Then
         Response.Cookies(HDWname) = ""
     End If
 Next
End If
End Sub
</script>

Thanks for the help!
0
 

Author Comment

by:Comptrib
ID: 37715349
You may want to see this instead...this is where the CAPTCHA image is located ;

Text file attached
CAPTCHA.txt
0
 

Author Closing Comment

by:Comptrib
ID: 37721292
I created a separate form as suggested to make it work. I think it was the easiest thing to do.

Thanks
0

Featured Post

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question