Monday, April 27, 2009

Posting to a .php site

I'm trying to expand my image search to include the nbii.gov image database, but their site is written using php instead of straight html. I don't know what makes it different, but I am pretty sure I'll need to interact with it differently than I did for my morphbank.org search. 

Here's the relevant line of source code: 
form action="search_results.php" method="post" enctype="application/x-www-form-urlencoded" name="frmSearch"
Anyone know about this and have suggestions for how I go about posting a search term to this form? Thanks! 

2 comments:

Greg said...

Hey Maddy,

POST requests are very much like GET requests -- what differs are just the details of how the data is sent. Instead of including your request parameters in the URL string (as in a GET), a POST transmits the same parameters in the underlying network packet. Sometimes they're actually interchangeable. Here are a couple links that might help:

http://www.exampledepot.com/egs/java.net/Post.htmlhttp://java.sun.com/docs/books/tutorial/networking/urls/readingWriting.htmlhttp://forums.sun.com/thread.jspa?threadID=645830Hope this helps,
Greg

Maddy said...

I think the wording of my question might have been incorrect. I'm using neither POST nor GET. Instead, I create a URLConnection object which can return an output stream. I append text to the output stream and then close the stream. In response, I get back an input stream containing the html for the resulting page.
I am not sure whether the process needs to be different when dealing with a site that has .php in its address.