# Net::HTTP and submitting forms

**URL:** <https://www.ruby-forum.com/t/net-http-and-submitting-forms/54136>\
**Category:** Ruby\
**Created:** [February 24, 2006, 12:13am UTC](https://www.ruby-forum.com/t/net-http-and-submitting-forms/54136 "2006-02-24T00:13:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![beachguy82](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/9dc877/32.png) [@beachguy82](https://www.ruby-forum.com/u/beachguy82)\
**Post date:** [February 24, 2006, 12:13am UTC](https://www.ruby-forum.com/t/net-http-and-submitting-forms/54136/1 "2006-02-24T00:13:40Z")

</div>

I have a little snippet of code I wrote but it doesn’t go to the correct  
page. The script pulls the data off of index.php but not  
index.php?pid=fact&person=chuck. What am I doing wrong?

require ‘net/http’  
res = Net::HTTP.post\_form(URI.parse(‘[http://www.4q.cc/index.php](http://www.4q.cc/index.php)’),  
{‘pid’=\>‘fact’, ‘person’=\>‘chuck’})  
puts res.body

charlie bowman  
[recentrambles.com](http://recentrambles.com)

---

<div class="post-metadata">

**Author:** ![beachguy82](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/9dc877/32.png) [@beachguy82](https://www.ruby-forum.com/u/beachguy82)\
**Post date:** [February 24, 2006, 6:33pm UTC](https://www.ruby-forum.com/t/net-http-and-submitting-forms/54136/2 "2006-02-24T18:33:30Z")

</div>

On Feb 23, 2006, at 5:13 PM, charlie bowman wrote:

> I have a little snippet of code I wrote but it doesn’t go to the  
> correct  
> page. The script pulls the data off of index.php but not  
> index.php?pid=fact&person=chuck. What am I doing wrong?
> 
> require ‘net/http’  
> res = Net::HTTP.post\_form(URI.parse(‘[http://www.4q.cc/index.php](http://www.4q.cc/index.php)’),  
> {‘pid’=\>‘fact’, ‘person’=\>‘chuck’})  
> puts res.body

#post\_form will put the parameters you pass in the request body. If  
your PHP script doesn’t care about GET or POST, you could make the  
request like any other GET, appending ?pid=fact&person=chuck to your  
URL.

---

<div class="post-metadata">

**Author:** ![beachguy82](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/9dc877/32.png) [@beachguy82](https://www.ruby-forum.com/u/beachguy82)\
**Post date:** [February 24, 2006, 8:50pm UTC](https://www.ruby-forum.com/t/net-http-and-submitting-forms/54136/3 "2006-02-24T20:50:59Z")

</div>

Thank you. The following worked fine.

res =  
Net::HTTP.get(URI.parse(‘[http://www.4q.cc/index.php?pid=fact&person=chuck](http://www.4q.cc/index.php?pid=fact&person=chuck)’))  
puts res
