1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Showing Captcha in a Pop up - PHP

Discussion in 'PHP & Perl' started by twisted_one, Jul 6, 2011.

  1. twisted_one

    twisted_one Regular Member

    Joined:
    Oct 11, 2009
    Messages:
    498
    Likes Received:
    82
    Friends,

    I need a help in PHP on displaying captchas in a pop up. I asked this question on Stack Overflow forum but they all bashed me saying what i am trying to do is illegal but none bothered even to guide how it can be achieved Lol I thought I would get some guidance here in our BHW hence posting it here...

    Assume that I have a site http://domain.com which has a form and captcha in it.

    I want to display the Captcha in a pop up so that I can manually solve and send it back to the server.

    In case of iMacros, we can do this easily using PROMPT Please<SP>enter<SP>Captcha: !VAR1

    How can we do this in Php? Any guidance will be greatly appreciated. Thanks!
     
  2. other_henry

    other_henry Junior Member

    Joined:
    Jun 1, 2011
    Messages:
    107
    Likes Received:
    19
    Occupation:
    Freelance coder, server guy
    Location:
    US
    Just put the php code that calls the captcha into the popup window.
     
  3. artizhay

    artizhay BANNED BANNED

    Joined:
    Nov 21, 2010
    Messages:
    1,867
    Likes Received:
    1,335
    May I ask why you want to have the CAPTCHA in a pop up? Why not just leave it in the form and process it with the rest of the form? I'm sure I can help, I just need a better understanding of what you're doing.
     
  4. weedsmoker

    weedsmoker Junior Member

    Joined:
    May 2, 2011
    Messages:
    190
    Likes Received:
    79
    Why is putting captcha in pop-up window illegal?:confused:
     
  5. twisted_one

    twisted_one Regular Member

    Joined:
    Oct 11, 2009
    Messages:
    498
    Likes Received:
    82
    Well, I can not think of a way to solve the captcha using any OCR technique. I do not want my code to rely on Decaptcher API either. So I thought solving captcha manually is the way to go...

    What my script does as of now is...

    1. I have a front-end form designed in simple HTML & CSS which will take some input parameters.
    2. On submitting this simple HTML form, my php script will be called which will post the parameters to another website http://domain.com (Let us say for registration or login purpose)
    3. If the http://domain.comwebsite has a captcha in it then just submitting the post parameters using php + curl will not help Rite? I need to solve the captcha too.

    So, before my php+cURL script submits my data to the other site, I want to solve the captcha manually... so, I need to show that captcha that is there on the http://domain.com in some pop up window sort of... so that I can manually key in the captcha and send it along with the post parameters.

    Any guidance, please?

    EDIT: Its something like how Onlywire shows captcha in a pop up and the submission happens at the backend...

    If you think my way of thinking is not better then please feel free to suggest a new solution. Thanks for your time!
     
    Last edited: Jul 7, 2011
  6. twisted_one

    twisted_one Regular Member

    Joined:
    Oct 11, 2009
    Messages:
    498
    Likes Received:
    82
    I dont know but all they say there is... Captcha is there for a reason and trying to by pass it is illegal.. for god's sake I am not trying to by pass it.. I am showing it in a pop up window and solve it manually... Well who knows whats in there mind!
     
  7. healzer

    healzer Jr. Executive VIP Jr. VIP Premium Member

    Joined:
    Jun 26, 2011
    Messages:
    2,364
    Likes Received:
    1,967
    Gender:
    Male
    Occupation:
    Marketing automation tools
    Location:
    Somewhere in Europe
    Home Page:
    Yes, I have seen this in the software SENukeX, when it creates accounts manually it shows the Captcha in a seperate window only.

    This is possible with programming skills of visual basic or C#.... but don't ask me the code, shouldn't be hard I think ;)
     
  8. twisted_one

    twisted_one Regular Member

    Joined:
    Oct 11, 2009
    Messages:
    498
    Likes Received:
    82
    Well, I would like to learn C# but for now I will stick with Php+cURL my current script is almost 60% over and its all in Php.
     
  9. artizhay

    artizhay BANNED BANNED

    Joined:
    Nov 21, 2010
    Messages:
    1,867
    Likes Received:
    1,335
    I'm not entirely sure it's possible in PHP. Those desktop programs can do it because they use more powerful languages. You're using cURL so how would you fetch the CAPTCHA before posting and not get it to change when actually submitting? Due to the language, if you load the external site in any way before POSTing with cURL, then when you do submit via cURL, the server will be expecting a different CAPTCHA because it's a new page request and therefore a new CAPTCHA.

    The only thing I see that's possible is that when you submit it, cURL will return the page and the page will most likely say, "Sorry, you didn't enter the correct security code" or something, but all your submitted data will still be saved in the form, so you could just open the cURL response in a popup and focus it only on the CAPTCHA so your user doesn't see the rest of the site.

    However, this relies entirely on the external site...if some data gets lost after the script realizes the CAPTCHA was wrong (often times, things like drop-down menus or radio buttons are back to their default values because of lazy programmers), then you won't be able to correct the data because I'm assuming you don't want your user to see the rest of the external site? It all depends on the site; some sites are great about preserving submitted data when catching a form error.

    Also, are you keeping the data that the user submits? If not, you might as well iframe the external site instead so that everything runs smoothly. However, if you are keeping data, I think what I suggested above is probably the only viable solution for PHP.
     
  10. other_henry

    other_henry Junior Member

    Joined:
    Jun 1, 2011
    Messages:
    107
    Likes Received:
    19
    Occupation:
    Freelance coder, server guy
    Location:
    US
    This can be done but might be tricky...

    You need to parse the data returned from the 1st site to extract the captcha image. You then need to display that image in your own form so you can solve it.

    You then submit your second form to the 2nd site.
     
  11. twisted_one

    twisted_one Regular Member

    Joined:
    Oct 11, 2009
    Messages:
    498
    Likes Received:
    82
    Guys,

    Thanks for the response .. I finally managed to get it work... What I am doing is.. maintaining the cookie information and download the captcha and display it in my pop up.

    The code base I used as an example is here

    Code:
    http://www.bitrepository.com/download-image.html
    Just sharing that link... though it might help somebody.
     
  12. shadow1200

    shadow1200 Junior Member

    Joined:
    May 14, 2011
    Messages:
    128
    Likes Received:
    32
    I Frame ?? simple :S