Click to See Complete Forum and Search --> : passing data using post ...
patimages
11-22-2006, 03:39 AM
Hi !
I am wondering ... I know it might sound stupid but I just do not know: is there a way to pass data from one address to an other one using post ?
Maybe have a look at my actual script that uses the get method to better understand:
//
if (strlen ($pieces [1])>"2") {echo 'window.open(\''.'http://www.mynextsite.com/blah.php?var1=1&var2='.$query.'\');';}
//
Would there be a way to pass my variables (var1 and var2) to mynextsite.com using post ????
Znupi
11-22-2006, 03:43 AM
Make a form with with two hidden fields which contain the data you need, then put a link like
<a href="javascript:void(0)" onClick="document.yourFormsName.submit()">
Eventually you can add a target="_blank" but I'm not so sure about that, test it, see if it works :)
patimages
11-22-2006, 03:56 AM
thanks !!!!
Just wondering whether there was a way without link ??? I know about popup blockers but my visitors have my site unrestricted for pop-ups.
MatMel
11-22-2006, 06:48 AM
You can put 'document.yourFormsName.submit()' in every JavaScript you want to ...
Znupi
11-22-2006, 01:58 PM
Yup, MatMel is right... you can put it on an onLoad event for example... :)
NightShift58
12-16-2006, 09:20 PM
The most "elegant" way to do this would be to stay within PHP and use cURL, where you can POST or GET without a link, as follows:
<?php
// A very simple PHP example that sends a HTTP POST to a remote site
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"http://www.mysite.com/tester.php");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,"postvar1=value1&postvar2=value2&postvar3=value3");
curl_exec ($ch);
curl_close ($ch);
?>The above example is plagiarized from http://curl.haxx.se/libcurl/php/examples/simplepost.html
cURL also gives you an option to collect and display the results of the page you are calling - much like file_get_contents()