Jump to content

Passing on $_POST variables


DanFTW

Recommended Posts

You're probably better off using form processing classes or functions, rather than seperate pages.

 

Example...

 

<?php

class forms
{

  function process($vars) {
    //Do your thang 
  }

}

$f = new forms;

  if(isset($_POST['submit']) && $_POST['submit'] != '') {
    $f->process($_POST);
  }
?>

once again,

you're better off with cURL()

 

let me show you an example:

 


<?php

function makeVars($array){
$x = 0;
foreach($array as $key => $val){
	$vars[$x] = $key . '=' . $val;
	$x++;
}

$variables = implode("&", $vars);

}

function Post($vars,$url){
        $ch = curl_init();
        curl_setopt($ch,CURLOPT_URL,$url);
        curl_setopt($ch,CURLOPT_POST,1);
        #curl_setopt($ch,CURLOPT_UPLOAD,1);
        curl_setopt($ch,CURLOPT_POSTFIELDS,$vars);
        curl_exec($ch);
        curl_close($ch);
}

// enter your post data here:
$postdata = array("caca" => "value", "key" => "val"); // enter as many values as you wish

$url = "http://www.website.com/script.php"; // where you want to post the data to

makeVars($postdata);

Post($variables, $url);

/*
IN THE URL THAT IS RECEIVING THE DATA,
PUT THIS CODE:

echo $_POST['caca'];
echo "<br />";
echo $_POST['key'];


*/

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.