Location: PHPKode > projects > SMS Web Sender > sms_web_sender/test/web_form_pre_filled.php
<?php 
/*
This file demonstrates SMS message details being submitted through HTML form and
then passed to SMS Web Sender along with the sites which should be used to 
attempt to send the message.
*/

// COMMENT OUT THIS LINE TO ENABLE
die('DISABLED - remove line '.__LINE__.' in '.basename(__FILE__).' to enable');

// for debugging reasons we enable all error reporting
// and output the <pre> tag to preserve text formatting
error_reporting (E_ALL);
echo '<pre>';

// include required classes
// SMS Web Sender requires HTTP Navigator 2.2 or later, you must define
// HTTPNAV_ROOT as SMS_Web_Sender will use it to find the relevant classes
define('HTTPNAV_ROOT', realpath('../../http_navigator/classes/').'/');
require_once('../classes/SMS_Web_Sender.php');

// set debug level
// Debug::level(DEBUG_OUTPUT_FILENAME);
Debug::level(DEBUG_OUTPUT_FILENAME | DEBUG_OUTPUT_LINE);

// create instance of SMS_Web_Sender
$sws =& new SMS_Web_Sender();

$message = '';

// check if form submitted
if (isset($_POST['message'])) {

    // add sites (uncomment lines and change 'user' 'pass' to your login
    // details for that site)
    //$sws->add_site('1rstwap', 'user', 'pass');
    //$sws->add_site('rbkuk');
    //$sws->add_site('boltblue', 'user', 'pass');
    //$sws->add_site('sms_ac', 'user', 'pass');
    //$sws->add_site('o2-genie', 'user', 'pass');

    // lets grab debug info, obviously you wouldn't want this on your own
    // site as it reveals a lot (including login details)
    ob_start();
    // attempt to send
    if ($sws->send($_POST['ccode'], $_POST['number'], $_POST['message'])) {
        $message = "Sent!";
    } else {
        $message = "Sorry, couldn't send :(";
    }
    $debug = ob_get_contents(); 
    ob_end_clean(); 
    $debug = '<textarea name="textfield" cols="50" rows="7">'.htmlspecialchars($debug).'</textarea>';
}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>SMS Web Sender 2 - Demo</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>

<body>
<div align="center">
  <h2>SMS Web Sender 2 - Demo</h2>

    <p><b><?php echo $message; ?></b></p>

    <?php if (isset($debug)) echo '<p><b>Debug:</b> ',$debug,'</p>'; ?>

  <form name="form" method="post" action="web_form_pre_filled.php">
    <table border="0" cellspacing="2" cellpadding="4">
      <tr> 
        <td align="right">Country code</td>
        <td align="left">+ 
          <input name="ccode" type="text" id="ccode" value="44" size="4" maxlength="4" value="<?php echo @$_POST['ccode']; ?>" /></td>
      </tr>
      <tr> 
        <td align="right">Number (including initial '0')</td>
        <td align="left"><input name="number" type="text" id="number" value="<?php echo @$_POST['number']; ?>" /></td>
      </tr>
      <tr> 
        <td align="right">Message</td>
        <td align="left"><textarea name="message" cols="50" rows="7"><?php echo htmlspecialchars(@$_POST['message']); ?></textarea></td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td align="left"><input type="submit" name="Submit" value="Send!" /></td>
      </tr>
    </table>
  </form>
  <p>&nbsp;</p>
</div>
</body>
</html>
Return current item: SMS Web Sender