<!DOCTYPE html>
<?php 
// echo "string";
include 'class/smstext.class.php';
$smstext = new smstext();
// Get the id given
$draft_id = $_GET['id'];
// delete draft
if (isset($_GET['delete'])) {
    $smstext->delete($_GET['delete']);
    header('Location:draftsms.php?delete=1');
    exit;
}
if (isset($_POST['submit-sms'])) {
    // get the field data
    $recipients = trim($_POST['recipient-phone']);
    $message = trim($_POST['smstext']);
    // $sent = $smstext->sendSms($recipients,$message);
    $sent = 'Success';
    // if there is an error stay on page and show error
    // only if the sms is sent
    // then save the da
    if ($sent == 'Success') {
        //save the data
        $is_draft = 0;
        $saved = $smstext->update($draft_id, $recipients, $message, $is_draft);
        // redirect to inbox and show sucess message
        header("Location: sentsms.php?sent=sucess");
        exit;
        // prevent the est of page from showing accidentaly
    }