Hi
I have a php page that has a select option menu populated from mysql data and that is working ok and am trying to get it to do the following process
1) select a users mobile number within the select option menu
2) sends a sms text message to the users mobile number
below is the script from send-sms-message.php
<?php
$db = mysqli_connect("localhost" , "", "") or die("Check connection parameters!");
// Optionally skip select_db and use: mysqli_connect(host,user,pass,dbname)
mysqli_select_db($db,"") or die(mysqli_error($db));
if (mysqli_connect_error()) {
die ('Failed to connect to MySQL');
}
$sqlCommand = "SELECT id, customer_name, customer_phone FROM repairs";
$query = mysqli_query($db, $sqlCommand) or die (mysqli_error($db));
echo '<form method="post" action="send-sms.php">';
echo '<select>';
echo '<option value="">Choose the mobile number</option>';
while($row= mysqli_fetch_assoc($query)){
echo '<option name="id" value="'.$row['id'].'">'.$row['customer_name'].' - '.$row['customer_phone'].'</option>';
}
echo '</select>';
echo '<input type="submit" value="Send SMS">';
echo '</form>';
?>
below is the script from send-sms.php
<?php
ini_set('display_startup_errors',1);
ini_set('display_errors',1);
error_reporting(-1);
function sendSMS($username, $password, $customer_phone, $message, $originator) {
$URL = 'http://api.textmarketer.co.uk/gateway/'."?username=$username&password=$password&option=xml";
$URL .= "&to=$customer_phone&message=".urlencode($message).'&orig='.urlencode($originator);
$fp = fopen($URL, 'r');
return fread($fp, 1024);
}
$db = mysqli_connect("localhost" , "", "") or die("Check connection parameters!");
// Optionally skip select_db and use: mysqli_connect(host,user,pass,dbname)
mysqli_select_db($db,"") or die(mysqli_error($db));
if (mysqli_connect_error()) {
die ('Failed to connect to MySQL');
}
$id = $_POST['id'];
$sqlCommand = "SELECT id, customer_name, customer_phone FROM repairs WHERE id = '$id'";
$query = mysqli_query($db, $sqlCommand) or die (mysqli_error($db));
$row = mysqli_query($db, $customer_phone);
if (isset($_POST["submit"])) {
//var_dump($customer_phone);
}
// Example of use
$response = sendSMS('DJkGc7', '97q84F', $customer_phone, 'Your PC/Laptop is ready for collection', 'ITDoneRight');
//var_dump($response);
?>
The coding gives me a errors on the send-sms.php page which is below
Notice: Undefined index: id in /home/sites/it-doneright.co.uk/public_html/admin/send-sms.php on line 24 Notice:
Undefined variable: customer_phone in /home/sites/it-doneright.co.uk/public_html/admin/send-sms.php on line 30
Warning: mysqli_query(): Empty query in /home/sites/it-doneright.co.uk/public_html/admin/send-sms.php on line 30
Notice: Undefined variable: customer_phone in /home/sites/it-doneright.co.uk/public_html/admin/send-sms.php on line 39
Hope someone can help please as can't get my around it to get it working