Jump to content

Pass varibles to include


belick

Recommended Posts

Maybe you could use Curl..

 

<?php
//set up variables
$url = "http://www.domainname.com/file.php";
$fields = "anything=something";

//execute Curl
$c = curl_init($url);
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($c, CURLOPT_CONNECTTIMEOUT, 0);
curl_setopt($c, CURLOPT_POSTFIELDS, $fields);   //sending over post variables here
$data = curl_exec($c);
curl_close($c);

 

While looking at some of my code I found another example on line.  Here it is..

 

<?php
//curl6.php

// populate the array containing the values to be posted.
$postfields = array();
$postfields['field1'] = urlencode('value1');
$postfields['field2'] = urlencode('value2');

$ch = curl_init();

// Follow any Location headers
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);

curl_setopt($ch, CURLOPT_URL, 'http://www.example.co.za/recipient2.php');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

// Alert cURL to the fact that we're doing a POST, and pass the associative array for POSTing.
curl_setopt($ch, CURLOPT_POST, 1);

curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);

$output = curl_exec($ch);
curl_close($ch);
print $output;
?>

 

Good luck

I am tring to pass a POST to an include in some way, here is what I had in mind:

 

$_POST[anything] = 'something';

 

into:

 

include "http://www.domainname.com/file.php";

 

when file is:

 

<?PHP

  echo "$_POST[anything]";

?>

 

Thanks

 

what you are saying is simply impossible because an included/required/required_once file is like pasting its raw unsent source code into it so it has no real location to send.

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.