如何使用PHP向多个号码发送短信?
我需要为我们的大学创建一个批量短信服务应用程序 以下文件是发送SMS的表单 index.php如何使用PHP向多个号码发送短信?,php,mysql,Php,Mysql,我需要为我们的大学创建一个批量短信服务应用程序 以下文件是发送SMS的表单 index.php <body> <?php //Code using curl //Change your configurations here. //--------------------------------- $username="XYZ"; $api_password="4dlfed5scaweod1"; $sender="test"; $domain="your_domain"; $
<body>
<?php
//Code using curl
//Change your configurations here.
//---------------------------------
$username="XYZ";
$api_password="4dlfed5scaweod1";
$sender="test";
$domain="your_domain";
$priority="1";// 1-Normal,2-Priority,3-Marketing
$method="POST";
//---------------------------------
if(isset($_REQUEST['send']))
{
$mobile=$_REQUEST['mobile'];
$message=$_REQUEST['message'];
$username=urlencode($username);
$api_password=urlencode($api_password);
$sender=urlencode($sender);
$message=urlencode($message);
$parameters="username=$username&api_password=$api_password&sender=$sender&to=$mobile&message=$message&priority=$priority";
$url="http://bulksms.gateway4sms.com/pushsms.php";
$ch = curl_init($url);
if($method=="POST")
{
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$parameters);
}
else
{
$get_url=$url."?".$parameters;
curl_setopt($ch, CURLOPT_POST,0);
curl_setopt($ch, CURLOPT_URL, $get_url);
}
curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1);
curl_setopt($ch, CURLOPT_HEADER,0); // DO NOT RETURN HTTP HEADERS
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // RETURN THE CONTENTS OF THE CALL
$return_val = curl_exec($ch);
if($return_val=="")
echo "Process Failed, Please check domain, username and password.";
else
echo "$return_val";
}
?>
<article>
<h1>SMS APPLICATION</h1>
<form name="f1" method="post">
<ul>
<li>
<label for="name"> Name:</label>
<input type="text" size="40" id="name" />
</li>
<li>
<label for="year">To the Students of:</label>
<select id="year">
<option>1st year</option>
<option>2nd year</option>
<option>3rd year</option>
<option>4th year</option>
</select>
</li>
<li>
<label for="message">Message:</label>
<textarea cols="50" rows="5" id="message" name="message"></textarea>
</li>
</ul>
<p>
<button type="submit" class="action" name="send">Send Message</button>
<button type="reset" class="right">Reset</button>
</p>
</form>
</article>
<footer>
</footer>
如何从数据库中检索发送人员的号码似乎您还没有尝试过。我可以给你一些想法
- 查询数据库并从电话簿表中检索结果。(假设查询将
从电话簿中选择姓名和号码
- 在数组中获取这些结果[姓名和手机号码]
- 使用一个循环,比如a
loop,并在其中添加cURL代码..这样for
for($i=0;$i)你试过什么?请先研究你的问题!谷歌搜索,“PHP数据库”非常感谢您的帮助…如何知道使用PHP从列表中选择哪个选项,即第一年第二年第三年第四年只需使用此
,也可以将您的echo$_POST['year'];
更改为id NAME number year 1 subh 90199492070 1st year 2 saefh 90199493050 2nd year 3 sawd 90199390450 1st year 4 suwd 90199543450 4th year