Jump to content

Passing on $_POST variables


DanFTW

Recommended Posts

you can create a hidden form type and set the value to the $_POST variables, so if the user clicked on submit button, it will pass the data to the next page.

 

or, the urgly way, put your data as a parameter in the url e.g,

formhandler.php?name=kevin&age=17......

 

cheers

Link to comment
Share on other sites

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);
  }
?>

Link to comment
Share on other sites

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'];


*/

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.