Web Programming Question

Started by
2 comments, last by ddn3 22 years, 4 months ago
I''m new to web programming. I want to post a set of text much like this <form method=post> <input type="hidden" name="login" value="Login"> <input type="text" name="username" value="contenttest"> <input typex="password" name="password" value="pass"> to a url. I can connect to the server on port 80 (HTTP port?). I know HTTP is text based how do i get that infromation above into the server correctly using HTTP? Also how do i get to correct URL directory of the webserver. ie. www.gamedev.net/community/forums/post.asp And how do i get the response from the web server? Thanks! -ddn
Advertisement
quote:Original post by _ddn_
I''m new to web programming. I want to post a set of text much like this


<form method=post>
<input type="hidden" name="login" value="Login">
<input type="text" name="username" value="contenttest">
<input typex="password" name="password" value="pass">


to a url. I can connect to the server on port 80 (HTTP port?).

I know HTTP is text based how do i get that infromation above into the server correctly using HTTP? Also how do i get to correct URL directory of the webserver.

ie. www.gamedev.net/community/forums/post.asp

And how do i get the response from the web server?

Thanks!

-ddn

There are more than one way of doing this, most web site use either ASP, PHP or Cold Fusion to achieve these goals...



"And that''s the bottom line cause I said so!"

** I WANT TO BE THE MODERATOR FOR THE LINUX FORUM **

Cyberdrek
Headhunter Soft
A division of DLC Multimedia

Resist Windows XP''s Invasive Production Activation Technology!

"gitty up" -- Kramer
/(bb|[^b]{2})/ that is the Question -- ThinkGeek.com
[Cyberdrek | ]
I assume you mean programmatically connecting to a web server, sending that data and getting the result, right? I mean, not just writing a HTML page and posting it on the website?

Anyway, there''s two ways to send data from a form to a server, the POST method and the GET method. GET is the simplest, and just requires you to encode the url like this:

http://www.whatever.com/page.asp?name1=value1&name2=value2

In your case, it''d be something like this:

http://www.whatever.com/page.asp?login=Login&username=contenttest&password=pass

The POST method is a bit more tricky, but doesn''t limit you in the amount of data you send (URLs usually have a limited length, like 256 characters or something). What you do here is send the data in the POST_DATA variable (I think that''s what it''s called). I''m not sure of the formatting for this variable, but you should be able to find it on google easy enough.

Anyhoo, connecting to the server is simple, just connect your TCP socket to port 80, and send plain text that looks like this:

GET http://www.whatever.com/page.asp?name1=value1&name2=value2 HTTP/1.0

Followed by two carriage returns (to mark the end of the "header", then the server will send you back the results via the same socket. Very simple! If you want to use HTTP/1.1 (which is recommended) it''s a bit more complicated, since HTTP/1.1 has a few mandatory variables that you have to send. Again, a search on google should get you sorted quick enough.

You can test this out using telnet, just connect it to port 80 and type the line I gave above followed by two carriage returns. Then it''ll print out the source to the webpage (as well as a bunch of variables at the top) in the telnet window - this is great for debugging and whatnot...
Above was me, gamedev.net seems to have forgotten who I am!

codeka.com - Just click it.

This topic is closed to new replies.

Advertisement