0

I'm using curl to retrieve some data on a post request, I'm having a little trouble with the fields as it doesn't seem to be correctly posting to the correct fields. The form consists of just a text area and a submit button.

<form action="other.php" name="form1" id="formID" method="post">
<textarea rows="1" cols="1" id="txtareaID" name="txtAreaName"></textarea>
<input type="submit" id="btnID" name="btnName" value="btnValue" title="btnTitle">

This is the fields variable:

$this->fields = "txtAreaName=". $this->num . "&btnName=btnID";

I am not entirely sure how to identify the submit button in this case..

and here is the curl array:

array(
  CURLOPT_URL   =>  $this->address,
  CURLOPT_POST =>   true,
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_POSTFIELDS => $this->fields
);
4
  • Have you tried with btnName=btnValue instead of btnName=btnID? Commented Jun 28, 2014 at 3:22
  • What do you mean by "not posting to the correct fields"? What fields is it posting to instead of the fields you want? Commented Jun 28, 2014 at 4:33
  • Make sure you use urlencode() if the field value can contain any special characters. Commented Jun 28, 2014 at 4:34
  • yea i am using urlencode(). I mean that curl is redirecting me to the page, but the page it's showing isn't what it would like had the data been posted so my only guess is that the fields are wrong Commented Jun 28, 2014 at 4:38

1 Answer 1

1

The submit button should be:

"&btnName=btnValue"

The value to the right of the = should be whatever is in the value= attribute of the button.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, still not working for me. The ID's and such I gave are just an example, if I give you the site could you have a look for me? Everything looks ok to me, I'm stuck as to what might be the problem

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.