Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
This is complex for me, but not most of you I guess.
I have a php script, which I need to POST a set of values (not array, not xml) to another script on more then one different URL's. This code needs to be inserted in the middle section of my existing php code.Code: Select all
<?php
#
# Existing PHP coding starts here...
#
blah blah blah
#
# Existing PHP coding ends here...
#
$value1 = "test value 1";
$value2 = "test value 2";
$value3 = "test value 3";
$value4 = "test value 4";
$value5 = "test value 5";
# Insert post here
# send values to http://www.url1.com/script.aspx -> No response required
# Insert post here
# send values to http://www.url2.com/script.php -> No response required
#
# Existing PHP coding starts here...
#
blah blah blah
#
# Existing PHP coding ends here...
#
?>If I was doing this via a HTML Page, it would be...
Code: Select all
<?php
$value1 = "test value 1";
$value2 = "test value 2";
$value3 = "test value 3";
$value4 = "test value 4";
$value5 = "test value 5";
?>
<html>
<body onLoad="document.process.submit();">
<form action="http://www.url1.com/script.aspx" method=POST name=process>
<input type=hidden name=value1 value="<?php echo $value1; ?>">
<input type=hidden name=value2 value="<?php echo $value2; ?>">
<input type=hidden name=value3 value="<?php echo $value3; ?>">
<input type=hidden name=value4 value="<?php echo $value4; ?>">
<input type=hidden name=value5 value="<?php echo $value5; ?>">
</form>
</body>
</html>
<?php
?>Problem with this script is it only covers 1 url, and outputs HTML to the browser.
ANY HELP Please.
I have looked at scripts using
See:
---------------------------------------------------------------------------------------------------
Code: Select all
<?php
function do_post_request($url, $data, $optional_headers = null)
{
$params = array('http' => array(
'method' => 'POST',
'content' => $data
));
if ($optional_headers !== null) {
$params['http']['header'] = $optional_headers;
}
$ctx = stream_context_create($params);
$fp = @fopen($url, 'rb', false, $ctx);
if (!$fp) {
throw new Exception("Problem with $url, $php_errormsg");
}
return;
}Problem is, I am not sure how to format the data (ie: $value1, $value2 etc)
I have no control over the external scripts, and they are expecting data as it would have been passed by a form.
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
[quote="[url=http://forums.devnetwork.net/viewtopic.php?t=30037]Forum Rules[/url] Section 1.1"][b]2.[/b] Use descriptive subjects when you start a new thread. Vague titles such as "Help!", "Why?" are misleading and keep you from receiving an answer to your question.[/quote]