Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Jun 2009
    Posts
    20
    Thanks
    1
    Thanked 0 Times in 0 Posts

    if (isset($_POST['submit']) ) QUESTION

    Hi there,

    I have a function which works after a Submit button is clicked only. How could I make it works without the needs to click the button, automatically?

    PHP Code:
        if (isset($_POST['submit']) ) {
            
    ### SECURING FORMS ###
                
    if ( function_exists('current_user_can') && !current_user_can('manage_options') )
                      die(
    __('Cheatin’ uh?'));
                
    check_admin_referer$mcsp_nonce );
            
    ### SECURING FORMS ###

            
    $optionarray_update = array (
                
    'mcsp_opt_numbers'                 => mcsp_aux_numbers_input_formatting($_POST['mcsp_opt_numbers']),
                
    'mcsp_opt_msg_no_answer'        => $_POST['mcsp_opt_msg_no_answer'],
                
    'mcsp_opt_msg_wrong_answer'     => $_POST['mcsp_opt_msg_wrong_answer'],
                
    'mcsp_opt_fieldname_useranswer' => mcsp_aux_fieldname_formatting($_POST['mcsp_opt_fieldname_useranswer']),
                
    'mcsp_opt_fieldname_mathresult' => mcsp_aux_fieldname_formatting($_POST['mcsp_opt_fieldname_mathresult'])
            );
            
    update_option('plugin_mathcommentspamprotection'$optionarray_update);

        } 

  • #2
    Regular Coder
    Join Date
    Mar 2008
    Posts
    235
    Thanks
    6
    Thanked 21 Times in 20 Posts
    Problem is, how else would you do it? If you can tell us that then we can answer better, it is possible to post a form without a button, but how do you want to do it? Javascript can do it on many singular events but if JS is disabled you need a backup.
    Andrew Sharman
    Web designer, developer and programmer.

    If you found my post helpful, why not give thanks! :)

  • #3
    New Coder
    Join Date
    Jun 2009
    Posts
    20
    Thanks
    1
    Thanked 0 Times in 0 Posts
    thanks for your answer. I attached the php file for you to see the whole code. When I use the plugin, it requires to click the Submit button, otherwise I got error

    Code:
    Warning: array_rand() [function.array-rand]: Second argument has to be between 1 and the number of elements in the array in /math-comment-spam-protection/math-comment-spam-protection.classes.php on line 71
    Attached Files Attached Files

  • #4
    Senior Coder
    Join Date
    May 2005
    Posts
    2,137
    Thanks
    96
    Thanked 72 Times in 72 Posts
    It appears to be saying that the second array item is greater then the array amount.
    Rowsdower! has accused me of having mental problems, and the administrator allowed it. What a great forum huh?

  • #5
    New Coder
    Join Date
    Jun 2009
    Posts
    20
    Thanks
    1
    Thanked 0 Times in 0 Posts
    what should I do then?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •