http://www.perlmonks.org?node_id=601146


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.

Replies are listed 'Best First'.
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>
      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?

      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
      A reply falls below the community's threshold of quality. You may see it by logging in.
A reply falls below the community's threshold of quality. You may see it by logging in.