Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Grab HTML generated by an ASP script!

Status
Not open for further replies.

ferdi

MIS
Nov 15, 2001
1
NL
I want to grab a HTML page generated by an ASP script (I know nothing about ASP) runing in the other host.They first validate username and password in an "login.htm" page using

<form action=&quot;login.asp&quot; method=&quot;POST&quot;>

Here is my problem.It seems that I cant pass the correct parameters to &quot;login.asp&quot;

The code below works fine if the remote script is PHP.


<title> abc </title>
<body>

<?

/* sendToHost
* ~~~~~~~~~~
* Params:
* $host - Just the hostname. No http:// or
/path/to/file.html portions
* $method - get or post, case-insensitive
* $path - The /path/to/file.html part
* $data - The query string, without initial question mark
* $useragent - If true, 'MSIE' will be sent as
the User-Agent (optional)
*
* Examples:
* sendToHost('* sendToHost('* 'param=First+Param&second=Second+param');
*/

function sendToHost($host,$method,$path,$data,$useragent=0)
{
// Supply a default method of GET if the one passed was empty
if (empty($method))
$method = 'GET';
$method = strtoupper($method);
$fp = fsockopen($host,80);
if ($method == 'GET')
$path .= '?' . $data;
fputs($fp, &quot;$method $path HTTP/1.1\n&quot;);
fputs($fp, &quot;Host: $host\n&quot;);
fputs($fp, &quot;Content-type: application/x-fputs($fp, &quot;Content-length: &quot; . strlen($data) . &quot;\n&quot;);
if ($useragent)
fputs($fp, &quot;User-Agent: MSIE\n&quot;);
fputs($fp, &quot;Connection: close\n\n&quot;);
if ($method == 'POST')
fputs($fp, $data);

while (!feof($fp))
$buf .= fgets($fp,128);
fclose($fp);
echo $buf;
}

?>

<?

sendToHost(' );
</body>


I receive this result:

HTTP/1.1 100 Continue Server: Microsoft-IIS/4.0 Date: Mon, 11 Mar 2002 22:32:07 GMT HTTP/1.1 302 Object moved Server: Microsoft-IIS/4.0 Date: Mon, 11 Mar 2002 22:32:07 GMT Connection: close Location: links.asp Content-Length: 130 Content-Type: text/html Set-Cookie: ASPSESSIONIDGQQQQQEC=MHFPIANDPEJBBPHBIMCCGPNA; path=/ Cache-control: private
Object Moved
This object may be found here.

Could you guys please help me with any idea how to solve this problem?

I really need help!!!!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top