Hi palanee83,
Thanks for the info.
Main Topics
Browse All TopicsHi,
1) Just wondering if we're supposed to be urlencoding the data before submitting via CURLOPT_POSTFIELDS in PHP?
2) And am I supposed to use CURLOPT_COOKIEJAR option when I've already successfully logged in.
I'm having trouble posting. I can login successfully but I can't seem to post. Any ideas?
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Business Accounts
Answer for Membership
by: palanee83Posted on 2009-04-15 at 04:34:21ID: 24146832
HI,
topt)
e: (.*);|U', $content, $results);
Answer #1
You can either use array or a string to send the post data ($postfields). If this $postfields is a query string then you should encode the url using urlencode() function. If its an array then its not required.
Answer #2
I used to set CURLOPT_COOKIEFILE as well as CURLOPT_COOKIEJAR to maintain session between the pages. The cookie file path should be absolute, it may not work if the path is relative.
Also i got the below information (just i copied and pasted here) from php.net User contribution note. Please give a try if above step not fix ur issue. (http://in.php.net/curl_se
Sometimes you can't use CURLOPT_COOKIEJAR and CURLOPT_COOKIEFILE becoz of the server php-settings(They say u may grab any files from server using these options). Here is the solution
1)Don't use CURLOPT_FOLLOWLOCATION
2)Use curl_setopt($ch, CURLOPT_HEADER, 1)
3)Grab from the header cookies like this:
preg_match_all('|Set-Cooki
$cookies = implode(';', $results[1]);
4)Set them using curl_setopt($ch, CURLOPT_COOKIE, $cookies);