# Getting user input from user on a webpage?

**URL:** <https://www.ruby-forum.com/t/getting-user-input-from-user-on-a-webpage/169897>\
**Category:** Ruby\
**Created:** [June 10, 2009, 3:35am UTC](https://www.ruby-forum.com/t/getting-user-input-from-user-on-a-webpage/169897 "2009-06-10T03:35:16Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![b1gtuna](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/8dc957/32.png) [@b1gtuna](https://www.ruby-forum.com/u/b1gtuna)\
**Post date:** [June 10, 2009, 3:35am UTC](https://www.ruby-forum.com/t/getting-user-input-from-user-on-a-webpage/169897/1 "2009-06-10T03:35:16Z")

</div>

Hello, I was wondering if there is a way for a ruby script to get a user  
input when it’s running on a webserver. I need a basic function like  
where there user can click on a button on a website which will invoke a  
method.

---

<div class="post-metadata">

**Author:** ![b1gtuna](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/8dc957/32.png) [@b1gtuna](https://www.ruby-forum.com/u/b1gtuna)\
**Post date:** [June 10, 2009, 2:59pm UTC](https://www.ruby-forum.com/t/getting-user-input-from-user-on-a-webpage/169897/2 "2009-06-10T14:59:33Z")

</div>

When you saying “it’s running a web server”, what caused it to run?  
Normally you’d expect a user message (eg HTTP GET from a web page) to  
trigger the script. The web server would run the script using the HTTP  
variables.

---

<div class="post-metadata">

**Author:** ![b1gtuna](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/8dc957/32.png) [@b1gtuna](https://www.ruby-forum.com/u/b1gtuna)\
**Post date:** [June 10, 2009, 3:02pm UTC](https://www.ruby-forum.com/t/getting-user-input-from-user-on-a-webpage/169897/3 "2009-06-10T15:02:04Z")

</div>

Mike S. wrote:

> When you saying “it’s running a web server”, what caused it to run?  
> Normally you’d expect a user message (eg HTTP GET from a web page) to  
> trigger the script. The web server would run the script using the HTTP  
> variables.

Hm can you briefly show me an example how I can pass a variable to a  
script using HTTP GET? I think I’m almost there with your tip!!

---

<div class="post-metadata">

**Author:** ![b1gtuna](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/8dc957/32.png) [@b1gtuna](https://www.ruby-forum.com/u/b1gtuna)\
**Post date:** [June 10, 2009, 4:36pm UTC](https://www.ruby-forum.com/t/getting-user-input-from-user-on-a-webpage/169897/4 "2009-06-10T16:36:50Z")

</div>

How you pick up what the user has typed in the web page will depend on  
the server you are running. For example in the Ruby CGI class you can  
ask for individual fields or access them all with CGI#params. Have a  
look at the Pickaxe book which I think is now bundled with the Ruby  
download.

---

<div class="post-metadata">

**Author:** ![b1gtuna](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/8dc957/32.png) [@b1gtuna](https://www.ruby-forum.com/u/b1gtuna)\
**Post date:** [June 10, 2009, 4:41pm UTC](https://www.ruby-forum.com/t/getting-user-input-from-user-on-a-webpage/169897/5 "2009-06-10T16:41:50Z")

</div>

Never realized the Pickaxe book is available for free. Although there is  
a new version, I think the fundamentals are the same. Thanks for the  
pointer 🙂

Mike S. wrote:

> How you pick up what the user has typed in the web page will depend on  
> the server you are running. For example in the Ruby CGI class you can  
> ask for individual fields or access them all with CGI#params. Have a  
> look at the Pickaxe book which I think is now bundled with the Ruby  
> download.
