Self post method in ruby cgi

Hi
I have done php programming before.. and just wondering if ruby cgi has
the capability to do the same thing as php :
example

index.rb:

#!/usr/bin/ruby
require 'cgi'
require 'mysql'
cgi = CGI.new

m = Mysql.new("localhost","root","","fosiul")
r = m.query("SELECT * FROM dc")

puts cgi.header

puts "<html>
<!DOCTYPE html>
<html>
<head>
<title>Report </title>
<link rel='stylesheet' href='style.css' type='text/css' />
</head><body>
<div>
<h1>Report </h1>
</div>
<div>

<form method='POST' action='index.rb'>

<select name='dc'>"
r.each_hash do |f|
     puts "<option value=#{f['dc']}>#{f['dc']}</option>"
end
puts "</select>
<input type='submit' value='Click here!' /> </form>

</body></html>"

Now when i will click on submit. i want stay on the same page index.rb
but wants to get the value of SELECT.

in php i would of done thing like this

<?php
if(isset($_POST['formSubmit']) )
{
  $varMovie = $_POST['dc'];

  // - - - snip - - -
}
else
...................
..........
?>

Can this concept be implemented here in ruby cgi ??

So basically after I click on submit, I want to stay on the same page as
index.rb and if page has a post value it will give the value ..

Can it be done ??

Thanks

···

--
Posted via http://www.ruby-forum.com/.

Can this concept be implemented here in ruby cgi ??

if cgi.params()["formSubmit"].empty?
   #do something
else
   #do something else

···

--
Posted via http://www.ruby-forum.com/\.