如何通过jQuery向PHP发送多个复选框数据

时间:2015-05-23 10:02:11

标签: javascript php jquery mysql ajax

<form id="foo">
<input type="text" name="voucher" placeholder="voucher ID" class="bill_fillter"/>
<input type="text" name="voucher" placeholder="voucher ID" class="bill_fillter"/>
<input type="text" name="voucher" placeholder="voucher ID" class="bill_fillter"/>
</form>

这是我的Jquery代码

 <script>

$("#foo").submit(function(event) {

/* Stop form from submitting normally */
event.preventDefault();

/* Clear result div*/
$("#result").html('');

/* Get some values from elements on the page: */
var values = $(this).serialize();

/* Send the data using post and put the results in a div */
$.ajax({
    url: "ajax_receipt_sms.php",
    type: "post",
    data: values,
    success: function(){
        alert("success");
        $("#result").html('Submitted successfully');
    },
    error:function(){
        alert("failure");
        $("#result").html('There is error while submit');
    }
});
});
</script>

ajax_receipt_sms.php

<?php
    $viuchid = $_POST['voucher'];
$sql1="SELECT * from usertable;
$result1 = mysql_query ($sql1);
 $row1 = mysql_fetch_array($result1)

      $CHEQUE_NO = $row1['CHEQUE_NO'];
        $cheqdate = $row1['CHEQUE_DATE'];
        $mobile = $row1['mobile'];
        $bank_name  = $row1['name'];
        $amt = $row1['Amount'];

        // split "dd-mm-yyyy" into an array of three elements
        $ddate = explode("-", $cheqdate);
        // retrieve the values
        $month = $ddate[1]; // mm
        $day = $ddate[2]; // dd
        $year = $ddate[0]; // yyyy
    ?>

<?php

$notify="Your message is successfully sent to:"."91".$mobile;
$message = "Dear Member, received with thanks Rs.".$amt. " by chq/cash dated " .$day.'-'.$month.'-'.$year. " drawn on " .$bank_name. "bank, from ".$_SESSION['socityname'].".";
$username = "xxx";
$password = "xxxxxx";
$sendername = "shoaib";
$url = "http://bulksms.mysmsmantra.com/WebSMS/SMSAPI.jsp?username=".$username."&password=".$password."&sendername=".$sendername."&mobileno=91".$mobile."&message=".urlencode($message);
// for sms send request
$ch=curl_init();
if($url)
curl_setopt($ch,CURLOPT_URL,$url);
$result = curl_exec($ch);
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);  
curl_close($ch);
?>

如何通过jQuery向PHP发送多个复选框数据并将短信发送给多个用户,当我向输入框添加多个数字时,它应该将Sms发送到所有数据到该数字。

1 个答案:

答案 0 :(得分:0)

我还认为需要在类型复选框的输入元素中使用类似voucher []的数组。