Skip to content Skip to sidebar Skip to footer

Php Forward Post Variables To Other Page

I have html form and I have to submit that form on same page where's that form, add POST variable and then all variables pass to next page. I tried this:

You have 2 alternatives here:

  1. convert $_POST in $_GET (for example http_build_query)
  2. if it's essential for you to have this data to be transmitted as POST, you can create a blank page containing form with input type="hidden" and then just submit it with javascript. A bit ugly but should work.

Solution 3:

you need to use cURL for this.

$fields_string = "name=".$_POST['name']."&email=.$_POST['email'];
    $url = "the website you want to post to";
    $cx = curl_init();
        curl_setopt($cx, CURLOPT_URL,$url);
        curl_setopt($cx, CURLOPT_POST, true);
        curl_setopt($cx, CURLOPT_POSTFIELDS,$fields_string);
        curl_setopt($cx, CURLOPT_SSL_VERIFYPEER, FALSE);
        curl_setopt($cx, CURLOPT_SSL_VERIFYHOST, FALSE);
        curl_setopt($cx, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($cx, CURLOPT_FOLLOWLOCATION, FALSE);
    $init_response = curl_exec($cx);
    curl_close($cx);

http://php.net/manual/en/book.curl.php

Post a Comment for "Php Forward Post Variables To Other Page"