chelnov63 Posted May 14, 2007 Share Posted May 14, 2007 I have a proxy.php file: <?php $data = file_get_contents("http://localhost/test/info.php?name=john"); echo $data; ?> and the info.php file is: <?php $name = $_GET['name']; echo $name; ?> The above works as expected - when i run proxy.php it echos out the name 'john' my question is how can i POST variables to the info.php file instead of using the GET method. Thanks in advance for your help Link to comment https://forums.phpfreaks.com/topic/51294-posting-using-file_get_contents/ Share on other sites More sharing options...
makka Posted May 14, 2007 Share Posted May 14, 2007 just change $_GET['name']; to $_POST['name']; just make sure that on your html form your you change your method aswell Link to comment https://forums.phpfreaks.com/topic/51294-posting-using-file_get_contents/#findComment-252615 Share on other sites More sharing options...
chelnov63 Posted May 14, 2007 Author Share Posted May 14, 2007 thanks for your reply.... that won't really work because the variables are not being POSTED..they are being sent by via the querystring... i need to know how to POST them .. Link to comment https://forums.phpfreaks.com/topic/51294-posting-using-file_get_contents/#findComment-252620 Share on other sites More sharing options...
neel_basu Posted May 14, 2007 Share Posted May 14, 2007 YOu cant use POST method with file_get_contents(). YOu have to use Curl for that. Link to comment https://forums.phpfreaks.com/topic/51294-posting-using-file_get_contents/#findComment-252633 Share on other sites More sharing options...
chelnov63 Posted May 14, 2007 Author Share Posted May 14, 2007 Hi neel, thanks fo rthe reply... how would do the above using the curl method? thanks..im on a bit of a deadline so your help is appreciated... Link to comment https://forums.phpfreaks.com/topic/51294-posting-using-file_get_contents/#findComment-252647 Share on other sites More sharing options...
neel_basu Posted May 14, 2007 Share Posted May 14, 2007 Read this page http://in.php.net/manual/en/function.curl-exec.php Link to comment https://forums.phpfreaks.com/topic/51294-posting-using-file_get_contents/#findComment-252649 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.