/    Sign up×
Community /Pin to ProfileBookmark

POST Request Question

How can I submit a POST request (using cURL), where the script will not actually be sent to the page, but will make a request in the background. Sometimes I need to send more than one in one script, but that is impossible when the script has stopped executing because it goes to another page. Is there a way to just send the request and read the response without going to the page?

to post a comment
PHP

6 Comments(s)

Copy linkTweet thisAlerts:
@chesemonkylomaauthorFeb 21.2007 — No one responded but I figured it out. It was redirecting, so it would automatically go to that page.
Copy linkTweet thisAlerts:
@darkninjaFeb 22.2007 — Sounds like you need some AJAX? Here's a very good and easy to use AJAX library

http://www.litfuel.net/mybic/index.html?page=download
Copy linkTweet thisAlerts:
@chesemonkylomaauthorFeb 22.2007 — No, AJAX is different, information is sent from the browser, instead of the server hosting the PHP script. cURL automatically prints the result of the request to the output, but it's possible to change that easily with one option.
Copy linkTweet thisAlerts:
@bokehFeb 23.2007 — Hard to know what you are asking; cURL is well documented in the manual though. As far as capturing output, if there is no other way you can use output buffering. For example: [code=php]ob_start();

echo 1;

ob_start();

echo 2;

ob_start();

echo 3;

$three = ob_get_clean();

$two = ob_get_clean();

$one = ob_get_clean();

echo $three . $one . $two;[/code]
Copy linkTweet thisAlerts:
@chesemonkylomaauthorFeb 23.2007 — No, there is an option for curl_setopt, which allows the output to be captured in to a variable, very simple.
Copy linkTweet thisAlerts:
@NightShift58Feb 23.2007 — Close...

cURL allows you to store the data received from a remote page, analogous to file_get_contents().

Screen output is not dealt with by cURL, just as file_get_contents() doesn't.
×

Success!

Help @chesemonkyloma spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.20,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...