使用api和php代码发送两个或更多收件人

时间:2017-09-29 10:21:54

标签: php html

我想通过两个或一组发送它,而不需要输入我的收件人的号码。请帮忙。

<?php
if ($_POST) {
    $number = $_POST['number'];
    $name = $_POST['name'];
    $msg = $_POST['msg'];

    //this is my free api code to send message .
    $api = "TR-ROSEM239665_1R9EJ";
    $text = $name . ":" . $msg;

    //This is my api code here .
    $result = itexmo($number, $text, $api);
    if ($result == "") {
        echo "iTexMo: No response from server!!!
        Please check the METHOD used (CURL or CURL-LESS). If you are using CURL 
       then try CURL-LESS and vice versa.   
        Please CONTACT US for help. ";
    } else if ($result == 0) {
        echo "Message Sent!";
    } else {
        echo "Error Num " . $result . " was encountered!";
    }
}
?>

<form method="POST" align='center' action="offering2.php">
    <table border="5" cellpadding="2" align="center" style="width:170%">


        <th><label for="name" size="12">Your Name</label></th>
        <td><input type="text" maxlength="10" class="form-control" id="name" 
                   placeholder="name" name="name" value="OSCA OFFICE" required></td><tr>
            <th><label for="number">Recipient Number</label></th>

            i can only send one recipient. 

            <td><input type="text" maxlength="11" class="form-control" id="number" 
                       placeholder="number" name="number" required></td><tr>
            <th><label for="msg">Your Message</label></th>
            <td><textarea rows="12" cols="99" name="msg" placeholder="message here" 
                          onkeyup="countChar(this)" required></textarea></td><tr>

        <h2 align="center" class="text-right" id="charNum">99</h2>
        <td></td>
        <td><button type="submit" class="btn btn-success">SEND</button></td>

1 个答案:

答案 0 :(得分:0)

你应该使用isset函数

<button type="submit" name="submit">send</button>


<?php
if (isset($_POST('submit'))) {
$number = $_POST['number'];
$name = $_POST['name'];
$msg = $_POST['msg'];

//this is my free api code to send message .
$api = "TR-ROSEM239665_1R9EJ";
$text = $name . ":" . $msg;

//This is my api code here .
$result = itexmo($number, $text, $api);
if ($result == "") {
    echo "iTexMo: No response from server!!!
    Please check the METHOD used (CURL or CURL-LESS). If you are using CURL 
   then try CURL-LESS and vice versa.   
    Please CONTACT US for help. ";
} else if ($result == 0) {
    echo "Message Sent!";
} else {
    echo "Error Num " . $result . " was encountered!";
}
}
?>