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);
}
register_rest_route