Jump to content

Recommended Posts

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;
Link to comment
https://forums.phpfreaks.com/topic/6565-cant-post/
Share on other sites

[!--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.
Link to comment
https://forums.phpfreaks.com/topic/6565-cant-post/#findComment-24058
Share on other sites

To all your servers current configuration state use the phpinfo function. Create a new file called phpinfo.php and put this in it:
[code]<?php

p.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.php

You 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.
Link to comment
https://forums.phpfreaks.com/topic/6565-cant-post/#findComment-24397
Share on other sites

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. :(
Link to comment
https://forums.phpfreaks.com/topic/6565-cant-post/#findComment-24491
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.