Anidazen Posted April 4, 2006 Share Posted April 4, 2006 Edit: Issues with not being able to post were sorted by removing the php opening and closing tags when I was editing to find out what the problem was. (Using the tags gets you a 406 browser error?) Can a moderator please change the topic title to something more suitable for my problem (ie. "Opening/parsing .CGI output issues") and remove this notice for me please? :)A script I'm working on requires opening a .CGI file as if it was a user entering data into a search form.The URL I need to parse is: [a href=\"http://www.bookryanair.com/skylights/cgi-bin/skylights.cgi\" target=\"_blank\"]http://www.bookryanair.com/skylights/cgi-bin/skylights.cgi[/a]I am having trouble understanding how to open files in this way. I cannot even bring up the page, never-mind send variables to it as a user would.Here is the code I am using so far -- to be honest, it's compiled from snippets and examples as much as my own knowledge, and very-heavily from the documentation - but in theory this should be working?I'd be very grateful if someone could let me know where I am going wrong. $boundary = "---------------------".substr(md5(rand(0,32000)),0,10); // Build the header $header = "POST /skylights/cig-bin/skylights.cgi HTTP/1.0\r\n"; $header .= "Host: bookryanair.com \r\n"; $header .= "Content-type: multipart/form-data, boundary=$boundary\r\n"; // attach post vars foreach($_POST AS $index => $value){ $data .="--$boundary\r\n"; $data .= "Content-Disposition: form-data; name=\"".$index."\"\r\n"; $data .= "\r\n".$value."\r\n"; $data .="--$boundary\r\n"; } $fp = fsockopen("bookryanair.com", 80); fputs($fp, $header.$data); while (!feof($fp)) { $itemstat .= fread($fp, 1000);}echo $itemstat; Quote Link to comment https://forums.phpfreaks.com/topic/6565-cant-post/ Share on other sites More sharing options...
Anidazen Posted April 5, 2006 Author Share Posted April 5, 2006 Nobody can help me? :( Quote Link to comment https://forums.phpfreaks.com/topic/6565-cant-post/#findComment-24032 Share on other sites More sharing options...
gizmola Posted April 5, 2006 Share Posted April 5, 2006 [!--quoteo(post=361788:date=Apr 4 2006, 04:39 PM:name=Anidazen)--][div class=\'quotetop\']QUOTE(Anidazen @ Apr 4 2006, 04:39 PM) [snapback]361788[/snapback][/div][div class=\'quotemain\'][!--quotec--]Nobody can help me? :([/quote]Yes, well it's a form, so one common solution to that is to use the CURL library calls. Quote Link to comment https://forums.phpfreaks.com/topic/6565-cant-post/#findComment-24058 Share on other sites More sharing options...
Anidazen Posted April 6, 2006 Author Share Posted April 6, 2006 Ok thankyou. I looked at them myself -- but I need to compile a special version of PHP?I am using rented webspace, not a dedicated server. How can I find out if this supports cURL? Quote Link to comment https://forums.phpfreaks.com/topic/6565-cant-post/#findComment-24389 Share on other sites More sharing options...
wildteen88 Posted April 6, 2006 Share Posted April 6, 2006 To all your servers current configuration state use the phpinfo function. Create a new file called phpinfo.php and put this in it:[code]<?phpp.hpinfo();//NOTE: make sure you remove the . between the p and the h?>[/code]Now save your file and upload this file to your webshot. Now go to www.mysite.com/phpinfo.phpYou should no get a big page full of all configuration settinsg for your PHP setup and a few server sided settings too. Now scroll down and see if you can see a big header saying CURL if there is then you have cURL available to you. Quote Link to comment https://forums.phpfreaks.com/topic/6565-cant-post/#findComment-24397 Share on other sites More sharing options...
Anidazen Posted April 6, 2006 Author Share Posted April 6, 2006 Thankyou very much for your help.CURL looks usable, and similar to file handle functions fopen() etc.The only thing I just cannot understand is how I can use that to send post or get variables (the ones which you can't just put in the URL). I've read through the documentation and couldn't work it out. :( Quote Link to comment https://forums.phpfreaks.com/topic/6565-cant-post/#findComment-24491 Share on other sites More sharing options...
Anidazen Posted April 6, 2006 Author Share Posted April 6, 2006 Anyone can link me a site or tutorial that will help explain how to pass variables with CURL?Yes I have read what I could understand in the PHP Docs and other places, but I just don't get it. :( Quote Link to comment https://forums.phpfreaks.com/topic/6565-cant-post/#findComment-24609 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.