Page 1 of 1

Re: sms checkbox php issue

Posted: Tue Jan 19, 2016 8:38 am
by Celauran

Code: Select all

echo '<label><input class="checkbox" type="checkbox" value="'.$row['customer_phone'].'" name="customer_phone[]" id="customer_phone"/> '.$row['customer_name'].'&nbsp;-&nbsp;'.$row['customer_phone'].'</label>';
...
$customer_phone = $db->real_escape_string($_POST['customer_phone']);
$smsmessage = $db->real_escape_string($_POST['smsmessage']);

// Example of use
$response = sendSMS('username', 'password', $customer_phone, $smsmessage, $from);
Your form specifies customer_phone[] as an array but your form processing ignores that fact. You need to iterate over the $_POST['customer_phone'] array and send the message to each one individually.

Re: sms checkbox php issue

Posted: Tue Jan 19, 2016 10:34 am
by Celauran
Stay far, far away from eval. Your existing code only needs a small tweak:

Code: Select all

$smsmessage = $db->real_escape_string($_POST['smsmessage']);

foreach ($_POST['customer_phone'] as $phone) {
    $response = sendSMS('username', 'password', $phone, $smsmessage, $from);
}

Re: sms checkbox php issue

Posted: Tue Jan 19, 2016 11:06 am
by Celauran