Click to See Complete Forum and Search --> : Submiting a form with php socket


resullivan
06-22-2005, 08:21 AM
How would I submit a form with a php socket? How does http submit a form? Is it part of the header? The form I am trying to submit is method=post and it is sent to a dll file.

resullivan
06-22-2005, 08:44 AM
I think that I found that with the post method it goes in the header but when I try it, it gives me a 404.

$in = "POST /tts/anontts.dll HTTP/1.1\r\n";
$in .= "Host: www.aaacooper.com\n User-Agent: PostIt\r\n";
$in .= "Content-Type: application/x-www-form-urlencoded\r\n";
$in .= "Content-Length: 14\r\n\r\n";
$in .= "SKEY0=" . urlencode(47994285) . "\r\n";

is there anything wrong with this? The variable is SKEY0 with the value 47994285

chrys
06-22-2005, 09:03 AM
If I understand correctly, you should looking into cURL, a member of the PEAR library. http://pear.php.net/

resullivan
06-22-2005, 09:06 AM
This is what I am looking at doing. It is just not working.
http://www.zend.com/zend/spotlight/mimocsumissions.php

chrys
06-22-2005, 09:30 AM
Ah, that's what I though, try out cURL:

http://us2.php.net/curl

bokeh
06-22-2005, 09:49 AM
There's no reason it can't be done with a straight fsockopen();

resullivan
06-22-2005, 10:08 AM
it is sending the header but I am getting this

400 Bad Request
The system could not process your request as submitted. This could be due to missing or malformed data, improper syntax, or a browser that is not standards compliant.

I have this

$request.="POST /tts/anontts.dll HTTP/1.1\n";
$request.="Host: www.aaacooper.com\n";
$request.="Content-type: application/x-www-form-urlencoded\n";
$request.="Content-length: ".strlen($data_string)."\n";
$request.="Connection: close\n";
$request.="\n";
$request.=$data_string."\n";

chrys
06-22-2005, 10:20 AM
Did you read this thread (http://www.webdeveloper.com/forum/showthread.php?t=70375)?

DaiWelsh
06-22-2005, 10:21 AM
Have you got a packet sniffer to see exactly what is sent and receievd? If so check it still looks ok and also compare it to a request from a browser which works (assuming you can get that utl working with a browser). If nothing jumps out then post the results here...

resullivan
06-22-2005, 11:11 AM
I have never used a packet sniffer but am trying and cannot find where it will show what my computer is sending the website. I cannot find the POST header anywhere.

resullivan
06-22-2005, 11:14 AM
I am preaty sure that it is half way working now but I am unsure of the variable and values to send. I wish I could find what my computer sends the website.

bokeh
06-22-2005, 11:27 AM
If you want a great packet monitor free download this (http://www.analogx.com/contents/download/network/pmon.htm). It lets you watch all the traffic on your network as well as just your local machine. I have a few packet monitors but I think this one is excellent. It can even be set to ignore the raw data and just show the text.

If you post the URL I will post the headers!

resullivan
06-22-2005, 11:37 AM
http://www.aaacooper.com/online/shipinfo/imagefetch.asp?PROnum=45488676

DaiWelsh
06-22-2005, 11:51 AM
Also if you would find it easier there are products for seeing specifically http headers, I don't have links here but something like "http interceptor" and "http sniffer" are two that seem to ring a bell, will probably show up on google. These act as local proxies for the web browser and will show you the http requests and responses without having to wade through a packet monitor output.

HTH,

Dai

bokeh
06-22-2005, 12:38 PM
That link returned this:
http://www.aaacooper.com/online/shipinfo/imagefetch.asp?PROnum=45488676

GET /online/shipinfo/imagefetch.asp?PROnum=45488676 HTTP/1.1
Host: www.aaacooper.com
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.7.8) Gecko/20050511 Firefox/1.0.4
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Language: en-gb,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Cookie: ASPSESSIONIDQQABSCSD=AELDIMLAMKFCJJPJDKOCMGCH

HTTP/1.x 200 OK
Server: Microsoft-IIS/5.0
Date: Wed, 22 Jun 2005 17:36:32 GMT
Content-Type: text/html
Cache-Control: private
Age: 0
Connection: close
----------------------------------------------------------
http://209.192.88.8/cooper/EIPAccessServlet

POST /cooper/EIPAccessServlet HTTP/1.1
Host: 209.192.88.8
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.7.8) Gecko/20050511 Firefox/1.0.4
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Language: en-gb,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: http://www.aaacooper.com/online/shipinfo/imagefetch.asp?PROnum=45488676
Content-Type: application/x-www-form-urlencoded
Content-Length: 200
command=SearchEIP&refreshData=false&showAnnotations=false&docid1=B05116AB.KNT&doctype1=BL&docid2=B05123AA.BVA&doctype2=DR&prostring=45488676%2C*%2C*%2C*%2C*%2C*%2C*%2C*%2C*%2CBL%2CDR%2C*%2C*&agemax=57

HTTP/1.x 200 OK
Date: Wed, 22 Jun 2005 16:37:12 GMT
Server: IBM_HTTP_Server/1.3.12.6 Apache/1.3.12 (Win32)
Set-Cookie: sesessionid=PB4YHYK3SR33UJKRZI3RM0Q;Path=/
Cache-Control: no-cache
Expires: Thu, 01 Dec 1994 16:00:00 GMT
Content-Type: text/html; charset=iso-8859-1
Content-Language: en
Age: 3488
Connection: close
----------------------------------------------------------
http://209.192.88.8/cooper/preload.html

GET /cooper/preload.html HTTP/1.1
Host: 209.192.88.8
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.7.8) Gecko/20050511 Firefox/1.0.4
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Language: en-gb,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: http://209.192.88.8/cooper/EIPAccessServlet
Cookie: sesessionid=PB4YHYK3SR33UJKRZI3RM0Q

HTTP/1.x 200 OK
Date: Wed, 22 Jun 2005 16:37:19 GMT
Server: IBM_HTTP_Server/1.3.12.6 Apache/1.3.12 (Win32)
Last-Modified: Wed, 13 Jun 2001 16:27:49 GMT
Content-Length: 284
Content-Type: text/html
Content-Language: en
Age: 3478
----------------------------------------------------------
http://209.192.88.8/cooper/Blank.html

GET /cooper/Blank.html HTTP/1.1
Host: 209.192.88.8
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.7.8) Gecko/20050511 Firefox/1.0.4
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Language: en-gb,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: http://209.192.88.8/cooper/EIPAccessServlet
Cookie: sesessionid=PB4YHYK3SR33UJKRZI3RM0Q

HTTP/1.x 200 OK
Date: Wed, 22 Jun 2005 16:37:20 GMT
Server: IBM_HTTP_Server/1.3.12.6 Apache/1.3.12 (Win32)
Last-Modified: Thu, 25 Apr 2002 20:02:19 GMT
Content-Length: 328
Content-Type: text/html
Content-Language: en
Age: 3478
----------------------------------------------------------



Obviously the first in each pair is my browser and the second is the web server responding.

resullivan
06-23-2005, 01:35 PM
I got it working thanks for your help. I am trying to auto print some images that the links to them look something like this, viewimage.jsp?document=blah. There is some type of session (I think) so even though I have the exact link it does not work for some reason. Is there a way to perform some type of javascript with a socket. By this I mean like if the webpage has on click is there a way to make a socket click?

bokeh
06-23-2005, 01:40 PM
I got it working thanks for your help. I am trying to auto print some images that the links to them look something like this, viewimage.jsp?document=blah. There is some type of session (I think) so even though I have the exact link it does not work for some reason. Is there a way to perform some type of javascript with a socket. By this I mean like if the webpage has on click is there a way to make a socket click? When a browser connects it does so using a socket type connection so all you need to do is emulate that connection.

resullivan
06-23-2005, 01:47 PM
I can get to the page that has the image however I am not sure how to make it print. There is a print button on the page that uses javascript. What I am doing now is making the connection then getting this link then putting an <img src="blah"> on my php page. This comes up with a red X but sometimes but if I go and check it on the website and then go back to my php page the image will come up.

resullivan
06-23-2005, 01:49 PM
If I could some how make the socket click the print button that would be great however the down fall to that is I would have to sit here and press print in the print box.

resullivan
06-23-2005, 02:27 PM
please disreguard the javascript question as I see now how dumb it is.