belick Posted January 3, 2008 Share Posted January 3, 2008 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 Link to comment https://forums.phpfreaks.com/topic/84235-pass-varibles-to-include/ Share on other sites More sharing options...
cunoodle2 Posted January 3, 2008 Share Posted January 3, 2008 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 Link to comment https://forums.phpfreaks.com/topic/84235-pass-varibles-to-include/#findComment-429014 Share on other sites More sharing options...
cooldude832 Posted January 3, 2008 Share Posted January 3, 2008 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. Link to comment https://forums.phpfreaks.com/topic/84235-pass-varibles-to-include/#findComment-429018 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.