Hi, im busy with processing results from an online dictionary with php, and i need to use a form with POST variables to do that. One part now works, the script first chooses a match from multiple words (which includes submitting a form), but after that I have to retrieve the page that holds the real description, which does not work for some reason.
This page works:
http://www1.oup.co.uk/elt/oald/bin/Web_lookup_options2.pl?search_word=@!#$&select=all_options%3Dfalse&numads=4&show_srch_form=true
this comes from the form at:
http://www1.oup.co.uk/elt/oald/home_main_3.htm
buit this page doesnt:
http://www1.oup.co.uk/elt/oald/bin/web_getentry2a.pl?which_entry=026906%23x1%23x1%23@!#$
comes from
http://www1.oup.co.uk/elt/oald/bin/Web_lookup_options2.pl?search_word=@!#$&select=all_options%3Dtrue&numads=4&show_srch_form=true
(the select box)
while they both work in my browser, the second one gives only a part of the page, as if it as if the variable has not been submitted. It returns http://www1.oup.co.uk/elt/oald/bin/web_getentry2a.pl
Does anyone know why this is? Is the second form a get form? Does anyone know how to get the second url in another way?
The script i used is the postit script:
function PostIt($DataStream, $URL) {
$URL = ereg_replace("http://", "", $URL);
$Host = substr($URL, 0, strpos($URL, "/"));
$URI = strstr($URL, "/");
$ReqBody = "";
while (list($key, $val) = each($DataStream)) {
if ($ReqBody) $ReqBody.= "&";
$ReqBody.= $key."=".urlencode($val);
}
echo $ReqBody;
$ContentLength = strlen($ReqBody);
$ReqHeader =
"POST $URI HTTP/1.0\n".
"Host: $Host\n".
"User-Agent: PostIt\n".
"Content-Type: application/x-www-form-urlencoded\n".
"Content-Length: $ContentLength\n\n".
"$ReqBody\n";
$socket = fsockopen($Host, 80, &$errno, &$errstr);
if (!$socket) {
$Result["errno"] = $errno;
$Result["errstr"] = $errstr;
return $Result;
}
$idx = 0;
fputs($socket, $ReqHeader);
while (!feof($socket) && $Result[$idx-1] != "0\r\n") {
if (substr($Result[$idx-1], 0, 2) == "0\r\n") echo "The End:".strlen($Result[$idx-1]);
$Result[$idx++] = fgets($socket, 128);
}
return $Result;
}
I called the script with:
echo get_ding("008937%2523x1%2523x1%2523");
function get_ding($target) {
$e["which_entry"] = $target;
$Result = PostIt($e, "http://www1.oup.co.uk/elt/oald/cgi-bin/web_getentry2a.pl");
if (isset($Result["errno"])) {
$errno = $Result["errno"]; $errstr = $Result["errstr"];
echo "<B>Error $errno</B> $errstr";
exit;
}
else {
while (list($key, $val) = each($Result)) $out .= $val;
}
return $out;
}
I hope i'm clear, and thanks in advance 😉.