call funcution when clicking submit

I’ve built a WordPress plugin, this plugin has a form in front-end using a shortcode
I need the submit button to do two things, first to send the entries to the database which I did it successfully. The second thing is to build a URL from entries and run it

this is the form code:

<form name="frm" action="#" method="post" enctype="multipart/form-data">
        <tr>
            <td><?php echo __( 'Your Name', 'msf')?></td>
            <td><input type="text" name="nm"></td>
        </tr>
        <tr>
            <td><?php echo __('Mobile no' , 'msf' )?></td>
            <td><input pattern="d*" maxlength="9" type="number" name="mob"></td>
        </tr>
        <tr>
            <td></td>
            <td><input class="button-primary" type="submit" value="<?php echo __('Send' , 'msf' )?>" name="ins" action=""></td>
           <!-- alert -->
            <div class="success_msg" style="display: none">Message
                Sent Successfully</div>

            <div class="error_msg" style="display: none">Message
                Not Sent, There is some error.</div>
        </tr>
    </form>

this is my function

function SMS_SEND($message,$numbers)
    {
    $text = urlencode($message);
    $to = $numbers;
    $user="";
    $pass="";
    $sender="";
    $ch = curl_init();
curl_setopt( $ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (X11; U; Linux i686; pt-BR; rv:1.9.2.18) Gecko/20110628 Ubuntu/10.04 (lucid) Firefox/3.6.18' );
curl_setopt( $ch, CURLOPT_URL, 'http://www.*****.com/sms/api/sendsms.php?username='.$user.'&password='.$pass.'&numbers='.$to.'&sender='.$sender.'&message='.$text );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
$result = curl_exec ( $ch );
curl_close ( $ch );
    return nl2br($result); 
     }

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

    <?php
        if(array_key_exists('button1', $_POST)) { 
            button1(); 
        } 
        function button1() { 
            echo "This is Button1 that is selected"; 
        } 
    ?> 

    <form method="post"> 
        <input type="submit" name="button1"
                class="button" value="Button1" /> 
        
    </form> 
</head> 

</html>

you call button click function this type you need more refrance follow this link


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x