Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Whats wrong with this code.

by imp (Priest)
on Feb 20, 2007 at 16:58 UTC ( #601146=note: print w/ replies, xml ) Need Help??


in reply to Whats wrong with this code.

"It doesn't work" doesn't give us enough information to diagnose the problem.

Does the form not submit? Then compare the html.
Does the script receiving the form input behave incorrectly? Then we need to see that code to see what it is doing. Please provide the smallest working example that still demonstrates the problem. By reducing your code like this you will likely find the problem, and if not it will help us find the problem quickly without digging through 300 lines of code.

The form looks ok, and the only significant difference I see is that you named the submit button '.submit' in the original code, and 'submit' in the 'simple print' version.


Comment on Re: Whats wrong with this code.
Re^2: Whats wrong with this code.
by kmullin5016 (Acolyte) on Feb 20, 2007 at 17:32 UTC

    Here is the HTML code generated by the use of CGI.pm, which does not work:

    <form method="post" action="secalert_display.cgi" enctype="application +/x-www-form-urlencoded" target="_top" name="new"> <input type="submit" name=".submit" value="Enter a new record for a Se +calert" /> <input type="hidden" name="MODE" value="new" /> </form>

    And here is the HTML generated by the use of the prints statements that DOES work.

    <form name='new' method='post' action='secalert_display.cgi' target='_ +top'> <input type='submit' value='Enter a new record for a Secalert'> <input type='hidden' name='MODE' value='new'> </form>

      So start with the HTML generated by CGI and then slowly modify it to be the same as the other, when it works you'll know what was breaking your receiving script. It looks like the only significant changes are the enctype and the name of the submit field so you should probably start by changing one of those. Once you know the problem it should be easy to figure out how to either fix your receiving script to handle it or change your generating script to produce the HTML you need.


      ___________
      Eric Hodges

        Seems to be a misunderstanding about what I mean when I say simply 'it doesn't work'. When it works, all is fine. I click on the submit button, and it calls the next cgi in line with the hidden field.

        But when it doesn't work, it takes forever. It never calls the next CGI. And, from what I can see on the status bar on my browser, it is attempting to call the second CGI, but it is not providing it with the hidden field. Under both situations, the HTML code that my CGI generates (either with the CGI.PM or with simply print statements, looks OK. It is very perplexing.

      You still didn't define what "does not work" actually means, and didn't include the code that is not handling the form input correctly.

      I know what I mean. Why don't you?

Re^2: Whats wrong with this code.
by kmullin5016 (Acolyte) on Feb 20, 2007 at 19:26 UTC

    I FOUND IT!

    The answer to all this was my use of the POST method. When I changed it to GET (and that is the default, adding even more to the confusion) it works just fine!!!! Thanks for everybody's time and effort to look at this.

      So there's no way that we could have tracked down this problem as in both of the code extracts you gave us, the form method was contained in a variable.

      I (together with, I expect, most of the people who tried to help you) assumed that the same variable would have the same value in each example. Another good example of why it's a bad idea to make assumptions.

      Update: Actually, imp points out to me that we didn't make assumptions. You showed us code that had "post" for both methods.

      Then why did the post method work just fine here

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://601146]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (3)
As of 2014-08-31 11:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (294 votes), past polls