/    Sign up×
Community /Pin to ProfileBookmark

Submiting a form with php socket

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.

to post a comment
PHP

19 Comments(s)

Copy linkTweet thisAlerts:
@resullivanauthorJun 22.2005 — 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.1rn";

$in .= "Host: www.aaacooper.comn User-Agent: PostItrn";

$in .= "Content-Type: application/x-www-form-urlencodedrn";

$in .= "Content-Length: 14rnrn";

$in .= "SKEY0=" . urlencode(47994285) . "rn";

is there anything wrong with this? The variable is SKEY0 with the value 47994285
Copy linkTweet thisAlerts:
@chrysJun 22.2005 — If I understand correctly, you should looking into cURL, a member of the PEAR library. http://pear.php.net/
Copy linkTweet thisAlerts:
@resullivanauthorJun 22.2005 — This is what I am looking at doing. It is just not working.

http://www.zend.com/zend/spotlight/mimocsumissions.php
Copy linkTweet thisAlerts:
@chrysJun 22.2005 — Ah, that's what I though, try out cURL:

http://us2.php.net/curl
Copy linkTweet thisAlerts:
@bokehJun 22.2005 — There's no reason it can't be done with a straight fsockopen();
Copy linkTweet thisAlerts:
@resullivanauthorJun 22.2005 — 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.1n";
$request.="Host: www.aaacooper.comn";
$request.="Content-type: application/x-www-form-urlencodedn";
$request.="Content-length: ".strlen($data_string)."n";
$request.="Connection: closen";
$request.="n";
$request.=$data_string."n";
Copy linkTweet thisAlerts:
@chrysJun 22.2005 — Did you read [URL=http://www.webdeveloper.com/forum/showthread.php?t=70375]this thread[/URL]?
Copy linkTweet thisAlerts:
@DaiWelshJun 22.2005 — 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...
Copy linkTweet thisAlerts:
@resullivanauthorJun 22.2005 — 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.
Copy linkTweet thisAlerts:
@resullivanauthorJun 22.2005 — 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.
Copy linkTweet thisAlerts:
@bokehJun 22.2005 — If you want a great packet monitor free [URL=http://www.analogx.com/contents/download/network/pmon.htm]download this[/URL]. 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!
Copy linkTweet thisAlerts:
@DaiWelshJun 22.2005 — 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
Copy linkTweet thisAlerts:
@bokehJun 22.2005 — That link returned this:[code=html]
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
----------------------------------------------------------

[/code]


Obviously the first in each pair is my browser and the second is the web server responding.
Copy linkTweet thisAlerts:
@resullivanauthorJun 23.2005 — 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?
Copy linkTweet thisAlerts:
@bokehJun 23.2005 — 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?[/QUOTE] When a browser connects it does so using a socket type connection so all you need to do is emulate that connection.
Copy linkTweet thisAlerts:
@resullivanauthorJun 23.2005 — 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.
Copy linkTweet thisAlerts:
@resullivanauthorJun 23.2005 — 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.
Copy linkTweet thisAlerts:
@resullivanauthorJun 23.2005 — please disreguard the javascript question as I see now how dumb it is.
×

Success!

Help @resullivan spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...