<?php 
include 'check.php';
include '../db.inc.php';
include 'check_msg.php';
$number=$_GET['user'];
$sql=mysqli_query($connectionString,"SELECT * FROM users WHERE number='$number'");
$get=mysqli_fetch_array($sql,MYSQLI_ASSOC);
$name=$get['firstname']." ".$get['lastname'];
$phone=str_replace("+","",$get['phone']);

if(isset($_POST['submit'])) {
	$subject=addslashes($_POST['subject']);
	$message=addslashes($_POST['message']);
	
	if(strlen($message) == 0) {
		$error_msg="<font color=red>Message is blank</font>";
	}
	else {
		include('../sendSMS.class.php');
		$gsm=array();
		$gsm[0]=$phone;	 
		$SMS=new SendSMSclass();
		$SMS->SendSMS($gsm,$message);
		$error_msg="<font color=green><strong>SMS Message Successfully Sent</strong></font>";
	}
}
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Administrator</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="css/style.css" rel="stylesheet" type="text/css">
</head>

<body>
<table width="96%" height="421" border="0" cellspacing="5">
  <tr>
    <td width="14%" height="274" valign="top" style="border:#003399 1px solid;"><table width="100%" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td height="21" bgcolor="#de0011" class="headers">Navigation</td>
      </tr>
      <tr>
        <td><table width="100%" border="0" cellspacing="1">
          <tr>
            <td bgcolor="#E8FFF8"><p><font size="2" face="Arial, Helvetica, sans-serif"><strong><a href="./">Home</a></strong></font></p></td>
          </tr>
           <tr>
            <td bgcolor="#E8FFF8"><p><font size="2" face="Arial, Helvetica, sans-serif"><strong><a href="smssender.php">SMS 
              Sender</a></strong></font></p></td>
          </tr>
          <tr>
            <td bgcolor="#E8FFF8"><p><font size="2" face="Arial, Helvetica, sans-serif"><strong><a href="add.php">Add 
              User</a></strong></font></p></td>
          </tr>
          <tr>
            <td bgcolor="#E8FFF8"><font size="2" face="Arial, Helvetica, sans-serif"><strong><a href="addact.php">Add Activity </a></strong></font></td>
          </tr>
          <tr>
            <td bgcolor="#E8FFF8"><a href="viewact.php"><font size="2" face="Arial, Helvetica, sans-serif"><strong>View Activities </strong></font></a></td>
          </tr>
          <tr>
            <td bgcolor="#E8FFF8"><a href="messages.php"><font size="2" face="Arial, Helvetica, sans-serif"><strong>View Messages (<?php echo $umsg; ?>)</strong></font></a></td>
          </tr>
          <tr>
            <td bgcolor="#E8FFF8"><a href="alerts.php"><font size="2" face="Arial, Helvetica, sans-serif"><strong>View Alerts</strong></font></a></td>
          </tr>
          <tr>
            <td bgcolor="#E8FFF8"><a href="sql.php"><font size="2" face="Arial, Helvetica, sans-serif"><strong>SQL</strong></font></a></td>
          </tr>
		  
          <tr>
            <td bgcolor="#E8FFF8"><font size="2" face="Arial, Helvetica, sans-serif"><strong><a href="logout.php">Log 
              Out</a></strong></font></td>
          </tr>
        </table>
        </td>
      </tr>
    </table>      
      <p>&nbsp;</p>
    </td>
    <td width="86%" valign="top" style="border:#003399 1px solid;"><form name="form1" method="post" action="">
      <table width="100%" border="0" cellpadding="3">
	  <tr>
	  <td width="9%">&nbsp;</td><td width="91%"><?php echo $error_msg; ?></td>
	  </tr>
	  <tr>
          <td valign="top">Recipient</td>
          <td><?php echo $name." (<strong>$phone</strong>)"; ?></td>
        </tr>
        <tr>
          <td valign="top">Message</td>
          <td><textarea name="message" cols="70" rows="20" id="message" maxlength="160" lengthcut="true"></textarea></td>
        </tr>
        <tr>
          <td valign="top">&nbsp;</td>
          <td><input name="submit" type="submit" id="submit" value="Send"></td>
        </tr>
      </table>
    </form>
	<script type="text/javascript" language="javascript" src="js/charcount.js"></script>
    </td>
  </tr>
</table>


</body>
</html>
