How to call a PHP function on submit button
My function is

function sendSMS($mobile, $msg, $sender, $sendPass, $sendID)
    {
        $msg=urlencode($msg);
        $ch = curl_init();
        $url="abusms.com/pushsms.php?username=kas&password=6117&sender=SHRIA&to=$mobile&message=$msg";
        //echo $url;
        $url=urlencode($url);
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_HEADER, 0);
        curl_setopt($ch, CURLOPT_POST, 1)or die("error1");
        curl_setopt($ch, CURLOPT_POSTFIELDS, $curlPost);
        $data = curl_exec($ch);
        echo $data;
        echo 
        curl_close($ch);
        return $data;
        //return substr($data,0,1);
    }
<tr>
<td colspan="3" align="center"><input type="submit" name="send" value="send" onclick="sendSMS($mobile, $msg, $sender, $sendPass, $sendID)"/> </td>
</tr>

Try this

<?php
	if(isset($_POST["send"]))
	{
		sendSMS('999999999','Message','432322245','pass','xxxxxx');
	}
?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Send Mail</title>
</head>

<body>
<form action="" method="post" name="frm_mail">
<table>
    <tr>
    <td colspan="3" align="center"><input type="submit" name="send" value="send"/> </td>
    </tr>
</table>
</form>
</body>
</html>
<?php
    function sendSMS($mobile, $msg, $sender, $sendPass, $sendID)
    {
		$msg=urlencode($msg);
		$ch = curl_init();
		$url="abusms.com/pushsms.php?username=kas&password=6117&sender=SHRIA&to=$mobile&message=$msg";
		//echo $url;
		$url=urlencode($url);
		curl_setopt($ch, CURLOPT_URL, $url);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
		curl_setopt($ch, CURLOPT_HEADER, 0);
		curl_setopt($ch, CURLOPT_POST, 1)or die("error1");
		curl_setopt($ch, CURLOPT_POSTFIELDS, $curlPost);
		$data = curl_exec($ch);
		echo $data;
		echo
		curl_close($ch);
		return $data;
		//return substr($data,0,1);
		
    }
?>

Hi karthik i am not getting the value of phone n msg
Please see n give suggestion

<?php
	if(isset($_POST["send"]))
	{
	     $name=$_POST['name'];
         $mobile=$_POST['phone'];
         $msg=$_POST['msg'];
         $sender="kacs";
         $sendPass="698117";
         $sendID="SHRDATIA";
		 sendSMS('$mobile','$msg','kacs','698117','SHRDATIA');
	}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<form  method="post" name="frm_mail" action="<?php echo $_SERVER['PHP_SELF'];?>">
<table>
<tr>
 <td>Name</td>
 <td>:</td>
 <td><input type="text" name="name"/></td>
</tr>
<tr>
<td>Mobile</td>
<td>:</td>
<td><input type="text" name="phone"/></td>
</tr>
<tr>
<td>Message</td>
<td>:</td>
<td><input type="text" name="msg"/></td>
</tr>

    <tr>
    <td colspan="3" align="center"><input type="submit" name="send" value="send"/> </td>
    </tr>
<?php
if(isset($_POST['send']))
{
$name=$_POST['name'];
$mobile=$_POST['phone'];
$msg=$_POST['msg'];
$sender="kacs";
$sendPass="698117";
$sendID="SHRDATIA";

}
?>
</table>
</form>
</body>
</html>
<?php
    function sendSMS($mobile, $msg, $sender, $sendPass, $sendID)
    {
		$msg=urlencode($msg);
		echo $msg;
		$ch = curl_init();
		$url="abulksms.com/pushms.php?username=kcs&password=697&sender=SHATIA&to=$mobile&message=$msg";
		echo $url;
		$url=urlencode($url);
		curl_setopt($ch, CURLOPT_URL, $url);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
		curl_setopt($ch, CURLOPT_HEADER, 0);
		curl_setopt($ch, CURLOPT_POST, 1)or die("error1");
		curl_setopt($ch, CURLOPT_POSTFIELDS, $curlPost);
		$data = curl_exec($ch);
		//echo $data;
		curl_close($ch);
		return $data;
		//return substr($data,0,1);
		
    }
?>

Hi,

Just remove single Quote from following line:
like.,
sendSMS($mobile,$msg,'kacs','698117','SHRDATIA');

May be it's workable...

<?php
    if(isset($_POST["send"]))
    {
		$name=$_POST['name'];
		$mobile=$_POST['phone'];
		$msg=$_POST['msg'];
		$sender="kacs";
		$sendPass="698117";
		$sendID="SHRDATIA";
		sendSMS('$mobile','$msg','kacs','698117','SHRDATIA');
    }
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    </head>
     
    <body>
    <form method="post" name="frm_mail" action="<?php echo $_SERVER['PHP_SELF'];?>">
    <table>
    <tr>
    <td>Name</td>
    <td>:</td>
    <td><input type="text" name="name"/></td>
    </tr>
    <tr>
    <td>Mobile</td>
    <td>:</td>
    <td><input type="text" name="phone"/></td>
    </tr>
    <tr>
    <td>Message</td>
    <td>:</td>
    <td><input type="text" name="msg"/></td>
    </tr>
     
    <tr>
    <td colspan="3" align="center"><input type="submit" name="send" value="send"/> </td>
    </tr>
    
    </table>
    </form>
    </body>
    </html>
    <?php
    function sendSMS($mobile, $msg, $sender, $sendPass, $sendID)
    {
		$msg=urlencode($msg);
		echo $msg;
		$ch = curl_init();
		$url="abulksms.com/pushms.php?username=kcs&password=697&sender=SHATIA&to=$mobile&message=$msg";
		echo $url;
		$url=urlencode($url);
		curl_setopt($ch, CURLOPT_URL, $url);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
		curl_setopt($ch, CURLOPT_HEADER, 0);
		curl_setopt($ch, CURLOPT_POST, 1)or die("error1");
		curl_setopt($ch, CURLOPT_POSTFIELDS, $curlPost);
		$data = curl_exec($ch);
		//echo $data;
		curl_close($ch);
		return $data;
		//return substr($data,0,1);
     
    }
    ?>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.