admin管理员组文章数量:1323193
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.*****/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);
}
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.*****/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);
}
Share
Improve this question
edited Sep 12, 2020 at 7:51
Gufran Hasan
6918 silver badges20 bronze badges
asked Sep 11, 2020 at 20:30
Mohamed MostafaMohamed Mostafa
681 silver badge4 bronze badges
3
|
1 Answer
Reset to default 0 <?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
本文标签: plugin developmentcall funcution when clicking submit
版权声明:本文标题:plugin development - call funcution when clicking submit 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742123998a2421854.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
register_rest_route
– Tom J Nowell ♦ Commented Sep 11, 2020 at 22:09