in reply to cgi check button

Hello, bigup401.

I am curious about a few things -- it looks like you might be taking your first dip into web form handling with Perl using the CGI module. Is that correct?

If so, there's a few things you might need to clarify.

As marto already indicated, you have <input>tags, but they are not inside <form>tags. I'm not terribly familiar with the inner workings of CGI, but I would interpret some of what marto says to mean that CGI might be limited to stuff in forms. I've only ever used it that way, so I wouldn't have any reason to question that.

Part of your question confuses me, though. You indicate you wish to make a decision on what to do based on whether or not a button has been clicked. Unless I'm missing something, your Perl script using CGIonly starts to run once the button has been clicked -- so I don't understand what you are trying to accomplish.

Can you bridge the gap in our understanding with a slow, patient, thorough, careful, and detailed explanation of what you've done, what you're trying to do, and which piece has you stuck?

Sorry to be so verbose, but I think your problem is conceptual, not code-related, so we need to get past that first.

Replies are listed 'Best First'.
Re^2: cgi check button
by bigup401 (Pilgrim) on Apr 24, 2015 at 13:33 UTC

    ok let me make it clear

    i want to disallow auto code execution

    thats why i asked if there any way i can do it. with submit button and make it manuel execution. because i have post and get in my script once the page reloads the script sends requst immediately to server. thats why i want to control that auto execution with submit button

    thats why i made simple html form! sorry i missed to put form tag. bt its example.

      I'm sorry, bigup401, we're just not connecting here.

           i want to disallow auto code execution

      I realize you probably think this is clear -- but it is not. It begs many questions, some of which are:

      1. What code are you trying to prevent execution of?
        • Perl CGI code from the server?
        • JavaScript code on the page?
        • JavaScript or other code entered into the form by the end user?
        • Some other kind of code?
      2. At what point are you trying to prevent this code execution?
        • Before the web page is fully displayed?
        • After the web page is displayed but before the user starts typing?
        • After the user starts typing but before they click the button? (This seems the likely answer but nothing is clear here)
        • Some other point in the user's experience?

      I wasn't kidding when I said to be slow, careful, detailed, and thorough. We are missing on more points than we are connecting on.

      Slow down, breathe deeply, maybe have a cup of hot cocoa. Then, relax, and try to explain the process you are expecting to see, and what you are trying to affect.

      i want to disallow auto code execution
      You're still being unclear.
      Do you mean you want to force people to use only your form in a browser only (and prevent, say, the use of LWP etc.)? If so, give up all hope, since people will find a way to automate your form anyway.

      Or do you mean that you want to know whether or not the submit button was pressed? If so, then you're halfway there. You have:
      <input type=submit name="make ponies appear" value="Submit button label">
      In your script, you would do:

      my $q = new CGI; if($q->param("make ponies appear")) { # do something with the form data } else { # show the form or something else }

      Or do you want something else? You'll need to be more specific.

      -Thomas
      "Excuse me for butting in, but I'm interrupt-driven..."