dcsimg
www.webdeveloper.com
Results 1 to 6 of 6

Thread: passing data using post ...

  1. #1
    Join Date
    Sep 2006
    Posts
    270

    passing data using post ...

    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:

    PHP Code:
    //
    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 ????

  2. #2
    Join Date
    Sep 2006
    Location
    Bucharest, RO
    Posts
    940
    Make a form with with two hidden fields which contain the data you need, then put a link like
    Code:
    <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

  3. #3
    Join Date
    Sep 2006
    Posts
    270
    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.

  4. #4
    Join Date
    Nov 2006
    Posts
    73
    You can put 'document.yourFormsName.submit()' in every JavaScript you want to ...

  5. #5
    Join Date
    Sep 2006
    Location
    Bucharest, RO
    Posts
    940
    Yup, MatMel is right... you can put it on an onLoad event for example...

  6. #6
    Join Date
    Dec 2006
    Location
    Escaz (Costa Rica) and Mallorca (Spain)
    Posts
    3,234
    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 Code:
    <?php
    // A very simple PHP example that sends a HTTP POST to a remote site
    $ch curl_init();
    curl_setopt($chCURLOPT_URL,"http://www.mysite.com/tester.php");
    curl_setopt($chCURLOPT_POST1);
    curl_setopt($chCURLOPT_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/exam...implepost.html
    cURL also gives you an option to collect and display the results of the page you are calling - much like file_get_contents()

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles