# CGI.new Can't Get the value?

**URL:** <https://www.ruby-forum.com/t/cgi-new-cant-get-the-value/119847>\
**Category:** Ruby\
**Created:** [November 11, 2007, 8:05am UTC](https://www.ruby-forum.com/t/cgi-new-cant-get-the-value/119847 "2007-11-11T08:05:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![waterhk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/ecb155/32.png) [@waterhk](https://www.ruby-forum.com/u/waterhk)\
**Post date:** [November 11, 2007, 8:05am UTC](https://www.ruby-forum.com/t/cgi-new-cant-get-the-value/119847/1 "2007-11-11T08:05:03Z")

</div>

i use ruby to write a cgi …  
but i can not use the CGI.new to get the “sk=go” value…  
who can help me to fix the problem ?

thanks

# ======================= index.html :
Test username : password : 
# ======================= test.rb :

#!C:/InstantRails/ruby/bin/ruby

require ‘cgi’;

POST = CGI.new

print “Content-type: text/html\r\n\r\n”  
print “This is a output test”  
print “  
”  
print “\>\>”+POST[‘sk’]

---

<div class="post-metadata">

**Author:** ![waterhk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/ecb155/32.png) [@waterhk](https://www.ruby-forum.com/u/waterhk)\
**Post date:** [November 12, 2007, 1:41am UTC](https://www.ruby-forum.com/t/cgi-new-cant-get-the-value/119847/2 "2007-11-12T01:41:37Z")

</div>

On Sun, 11 Nov 2007 02:05:02 -0500, Zeuxis Lo wrote:

> i use ruby to write a cgi …  
> but i can not use the CGI.new to get the “sk=go” value… who can help me  
> to fix the problem ?

It can’t, because you made a POST query, so it’s using the [] operator  
to  
store POST data. If you want to access the query string, you can still  
do  
so with CGI#query\_string, but you’ll have to decode it yourself.

(I use this much more simply: I have a script “testframework” that I  
call  
as testframework?experimentname – no name=value and encoding stuff to  
parse – and testframework has several forms that post back to itself  
using the same URL)

–Ken
