Hamhame
Hamhame

Reputation: 47

Post form includes captcha by httpPost

I want use page that has this form:

<form method="post" action="modules.php?name=search">
<input onkeypress=FKeyPress(this); onkeydown=FKeyDown(this); type="text" style="text-align:center" name="name"        size="30">&nbsp;</p>
 <img src='captcha.php' id='captcha' /><br /><br /><a href='#'  onclick='document.getElementById("captcha").src="captcha.php?"+Math.random();document.getElementById("captchaf").focus ();'id='change-image'>change</a><br/><p><strong>Enter captcha</strong><br>
 <input name="captcha" id="captchaf" type="text" style="text-align:center"></p><br />
 <input name="fbrsecured" type="hidden" value="">
 <input name="action" type="hidden" value="FBSend">
 <p><input type="submit" name="submit" value="search"></p>
 </form>

and I show use this:

    EditText edcap = (EditText) findViewById(R.id.cap);
    ImageView cap = (ImageView) findViewById(R.id.capt);
    try{
        String url1 = "mysiteaddress/captcha.php";
        URL ulrn = new URL(url1);
        HttpURLConnection con = (HttpURLConnection)ulrn.openConnection();
        InputStream is = con.getInputStream();
        Bitmap bmp = BitmapFactory.decodeStream(is);
        if (null != bmp)
            cap.setImageBitmap(bmp);
        else
            System.out.println("The Bitmap is NULL");

        }catch(Exception e){}
    String capt = edcap.getText().toString();
    HttpPost httpPost = new HttpPost("http://eservice.postcode.post.ir/modules.php?name=Postalcode2");  
    List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();  
    nameValuePairs.add(new BasicNameValuePair("name", Name));  
    nameValuePairs.add(new BasicNameValuePair("captcha", Capt)); 
    nameValuePairs.add(new BasicNameValuePair("fbrsecured", ""));
    nameValuePairs.add(new BasicNameValuePair("action", "FBSend"));
    nameValuePairs.add(new BasicNameValuePair("submit", "search"));

I show captcha and enter in edcap but Incorrect Captcha errors occurred.

Upvotes: 2

Views: 1140

Answers (1)

Hamhame
Hamhame

Reputation: 47

finally I found the answer,I used 2 httpclient and this changed the cookie and caused the Incorrect Captcha error

Upvotes: 1

Related Questions