Firstly thank you for looking at this issue. I have very basic understanding on HTML and even less of PHP. I have set up two files on a test server with an API send to a SMS broadcast however the test messages are not displaying the data entered in the HTML form.
I am sure the issue is probably incorrect formatting but I have sat here for two hours trying combinations without success.
Basically I need a HTML form that an operator enters data and it sends this in a SMS via API using a PHP script. There is more I need to do to this script but If i get the basics issue here answered I might be able to navigate my way through
Please see below:
HTML FORM:
<html>
<body>
<form action="xy2p1.php" method="get">
Pick Up Date: <input type="text" name='date'><br>
Pick Up Time: <input type="text" name='time'><br><br>
Pickup Address: <input type="text" name='pua'><br>
Drop Of Address: <input type="text" name='doa'><br>
Passenger: <input type="text" name='passenger'><br>
No of Pax : <input type="text" name='pax'><br>
<input type="submit">
</body>
</form>
</html>
now this should send the data to the PHP file which is named as per the form action above.
PHP FILE
<?php
function sendSMS($content) {
$ch = curl_init('https://api.smsbroadcast.com.au/api-adv.php');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $content);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec ($ch);
curl_close ($ch);
return $output;
}
$username = 'xxxxx';
$password = 'xxxx';
$destination = 'xxxx';
$source = 'SampleCompany';
$text = 'date','time','pua','doa','passenger','pax';
$ref = 'abc123';
$content = 'username='.rawurlencode($username).
'&password='.rawurlencode($password).
'&to='.rawurlencode($destination).
'&from='.rawurlencode($source).
'&message='.rawurlencode($text).
'&ref='.rawurlencode($ref);
$smsbroadcast_response = sendSMS($content);
$response_lines = explode("\n", $smsbroadcast_response);
foreach( $response_lines as $data_line){
$message_data = "";
$message_data = explode(':',$data_line);
if($message_data[0] == "OK"){
echo "The message to ".$message_data[1]." was successful, with reference ".$message_data[2]."\n";
}elseif( $message_data[0] == "BAD" ){
echo "The message to ".$message_data[1]." was NOT successful. Reason: ".$message_data[2]."\n";
}elseif( $message_data[0] == "ERROR" ){
echo "There was an error with this request. Reason: ".$message_data[1]."\n";
}
}
?>
Any ideas where i am going wrong?
Thanks!