[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

check form parameters

Matthew Margolis

1/28/2005 12:14:00 AM

What would be the best way to check if a user enters a value into a form
using ruby cgi?

I have some code that should only run if the user is uploading a file
but nil tests and key tests don't seem to prevent the code from
executing even if they don't upload anything.

two things I have tried(that didn't work) can be found below. Perhaps I
am missing something obvious?

if cgi.has_key?('upload')
#stuff to do if there is an image to upload
end

unless cgi.params['upload'].first.nil?
#stuff to do if there is an image to upload
end


Here is the form itself
--------------------
<FORM ENCTYPE="multipart/form-data" action="imageadmin.rb" method="post">
<%imageArray.length.times do |count|%>
<img src="<%=imageArray[count]%>">
<BR />
Comment:<input type="text" name="comment"
value="<%=commentArray[count]%>">
<BR />
Number:<input type="text" name="order"
value="<%=imageArray[count][0..2] %>">
<BR />
Delete:<input type="checkbox" name="delete"
value="<%=imageArray[count]%>">
<BR />
<%end%>
<BR />
<BR />
<input type="file" name="upload">
Comment:<input type="text" name="uploadcomment" value="">

<BR />
<input type="submit" value="Submit">
</FORM>
----------------------------


Thank you,
Matthew Margolis


1 Answer

Kirby Grant

8/14/2012 1:54:00 PM

0


On 10-Aug-2012, BeamMeUpScotty <ThenDestroyEverything@blackhole.nebulax.com>
wrote at alt.politics.economics:

> On 8/10/2012 12:23 PM, the green flash wrote:
> > On 8/10/2012 10:12 AM, BeamMeUpScotty wrote:
> >> On 8/9/2012 10:11 PM, the green flash wrote:
> >>> On 8/9/2012 5:12 PM, Sid9 wrote:
> >>>>
> >>>> "the green flash"<just@sun.set> wrote in message
> >>>> news:k01aqk$32n$15@dont-email.me...
> >>>>> On 8/9/2012 2:33 PM, Robert A. Leffingwell wrote:
> >>>>>
> >>>>> (disingenuously munged followups to alt.idiots, like the coward he
> >>>>> is)
> >>>>>
> >>>>>
> >>>>>> "the green flash"<just@sun.set> wrote in message
> >>>>>> news:k00pk1$l2j$2@dont-email.me...
> >>>>>>
> >>>>>>> ECONOMYUpdated August 8, 2012, 4:33 p.m. ET.'Better Off?' Theme
> >>>>>>> Framing Election .
> >>>>>>>
> >>>>>>> ALLENTOWN, Pa.?Are you better off than you were four years ago?
> >>>>>>> Ronald
> >>>>>>> Reagan's famous question to voters in his 1980 campaign now looms
> >>>>>>> over
> >>>>>>> the 2012 presidential election
> >>>>>>
> >>>>>> That was 1980 when Volcker forced Carter to pay the bills for
> >>>>>> Vietnam
> >>>>>
> >>>>> I'm sorry, Reagan was elected in 1980 and carried Volcker forward
> >>>>> until his lower tax policies could take hold and fuel the next 2
> >>>>> decades of growth:
> >>>>>
> >>>>> http://old.nationalreview.com/kudlow/kudlow200406...
> >>>>>
> >>>>>
> >>>>> June 10, 2004, 9:15 a.m.
> >>>>> Reagan?s Link
> >>>>> He understood the connection between economic growth at home and
> >>>>> American strength overseas.
> >>>>>
> >>>>>
> >>>>>
> >>>>> Economists were vexed during the 1970s, as unemployment and
> >>>>> inflation
> >>>>> rose together to stifle economic growth and all forms of investment.
> >>>>> The Keynesian Phillips-curve paradigm, whereby employment and
> >>>>> inflation are supposed to move in opposite directions, completely
> >>>>> broke down. The Ivy League formula of increasing the money supply to
> >>>>> spur growth, and high taxes to hold back inflation, had failed
> >>>>> utterly.
> >>>>>
> >>>>> Between the late 1960s and 1980, the U.S. inflation rate rose from 2
> >>>>> percent to 14 percent, while the unemployment rate gradually drifted
> >>>>> higher, from 4 percent to almost 10 percent. It was a period of
> >>>>> decline for the country. Americans were demoralized.
> >>>>>
> >>>>> As stagflation became more deeply embedded in the U.S. economy,
> >>>>> Soviet
> >>>>> adventurism in Central and South America, Asia, and elsewhere around
> >>>>> the world became more pronounced. The Soviets saw the U.S. cut and
> >>>>> run
> >>>>> from Vietnam. Our Cold War adversary saw nothing but weakness
> >>>>> emanating from the U.S.
> >>>>>
> >>>>> Ronald Reagan changed all that. From the moment of his swearing-in
> >>>>> in
> >>>>> Jan? uary 1981, with his extraordinarily strong character and deep
> >>>>> and
> >>>>> abiding faith in God, Reagan acted relentlessly to revive the
> >>>>> nation.
> >>>>>
> >>>>> More than any modern president, Reagan understood the link between
> >>>>> economic growth at home and American strength overseas. It was the
> >>>>> Gipper?s most brilliant insight. He acted swiftly to show our
> >>>>> enemies
> >>>>> that we would produce the necessary economic resources to do
> >>>>> whatever
> >>>>> it would take, for however long was necessary, to triumph over the
> >>>>> Communist menace.
> >>>>>
> >>>>> Immediately upon assuming office, he reversed the economic policy of
> >>>>> the decline years. He brought down marginal tax rates, restoring the
> >>>>> incentives necessary for economic growth. He gave Federal Reserve
> >>>>> chairman Paul Volcker the strong ground to stand on, allowing him to
> >>>>> harden the value of the dollar and slay inflation.
> >>>>>
> >>>>> At bottom, what became known as Reaganomics was a new pro-growth
> >>>>> policy mix of tax incentives at the margin and stable money. But
> >>>>> there
> >>>>> was more. The Californian launched a massive military buildup
> >>>>> totaling
> >>>>> about $1.5 trillion. He deregulated oil prices, proving the
> >>>>> conventional wisdom wrong as energy became much cheaper. He launched
> >>>>> U.S.-Canadian free trade. He was unyielding in his opposition to the
> >>>>> air-traffic controllers? strike, firing thousands of these
> >>>>> government
> >>>>> workers and ending the anti-growth union stranglehold on private
> >>>>> industry. He created individual retirement accounts and 401(k)s,
> >>>>> giving birth to the investor class. He also slashed social spending
> >>>>> by
> >>>>> reducing domestic program levels (excluding Social Security and
> >>>>> health
> >>>>> care) by nearly $50 billion in 1981. That amount would come to about
> >>>>> $90 billion today.
> >>>>>
> >>>>> By 1986, Reagan?s tax-reform plan left two marginal rates of 28
> >>>>> percent and 15 percent, a long stone?s throw from the 70 percent top
> >>>>> rate he had inherited. His plan also cut about 2,000 pages from the
> >>>>> tax code.
> >>>>>
> >>>>> Ideas matter. Results quickly followed for Reagan. Between 1982 and
> >>>>> 1989, the economy grew, adjusting for inflation, by 35 percent: more
> >>>>> than 4.5 percent per year. As growth was restored, tax revenues came
> >>>>> flowing in. Income-tax revenues grew by 50 percent during this
> >>>>> period
> >>>>> even as tax rates dropped. By 1986, the inflation rate had fallen to
> >>>>> 1
> >>>>> percent. By the end of his term, unemployment had dropped to 5.5
> >>>>> percent. Interest rates had plunged. The stock market had soared.
> >>>>>
> >>>>> From July 1982 through the end of 1988, the S&P 500 averaged a
> >>>>> near 21
> >>>>> percent annual gain. Brand-new industries arose in computing,
> >>>>> software, communications, and the Internet ? original endeavors that
> >>>>> completely streamlined and transformed the American economy for the
> >>>>> decades to come. In effect, Reaganomics launched a 20-year boom, the
> >>>>> longest prosperity period in the 20th century.
> >>>>>
> >>>>
> >>>> St. Reagan spent and borrowed his way to prosperity.
> >>>
> >>> And we all benefited richly from his wisdom and guidance.
> >>>
> >>> You may send a thank you letter to his library.
> >>
> >>
> >> And Obama has yet to adjust his GDP numbers for inflation....
> >
> > Well now, as grim as reality is, one can hardly blame him for that
> > sleight of hand, eh?
>
>
> Same as looking at home mortgages that get a notice for being late on
> payments.
>
> This month there were less, but it's still 10% more/worse than it was a
> year ago.....
>
>
> The truth won't get in the way of Obama and his Democrat support.
>
>
> Democrats have created a Matrix to convince you life is good.... you
> might call it the Liberal-Socialist "MACHINE" has created your matrix.
>
>

So perhaps there is a sense in which the Democratic message is somewhat
built on a foundation of sand, but at least that is infinitely better than
the Republican foundation which is all based on removing freedoms, enforcing
religious intolerance, dictatorial controls over morals and the gradual
deconstruction of the United States of America. Republicans have NOTHING to
offer. All they want to do is take away. They have no interest except the
profits of the super rich.