PHP Classes

File: simple_form_example.php

Recommend this page to a friend!
  Classes of ikhsan   Gammu SMS Inject   simple_form_example.php   Download  
File: simple_form_example.php
Role: Example script
Content type: text/plain
Description: an example to demonstrate mass sms using simple html form
Class: Gammu SMS Inject
Send SMS messages using Gammu MySQL storage
Author: By
Last change: change the file type from html to plain text
Date: 12 years ago
Size: 2,791 bytes
 

Contents

Class file image Download
<?php
//error_reporting(E_WARNING);
if(isset($_POST['number']))
{
    include
'sms_inject.php';
   
$mysql_res = mysql_connect('localhost','root','');
   
mysql_select_db('gammu',$mysql_res);
   
   
$smsd=new sms_inject($mysql_res);
   
$smsd->mass_sms(mysql_escape_string($_POST['msg']),$_POST['number']);
}
?>
<!DOCTYPE html>
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <meta name="author" content="ikhsan" />

    <title>add field</title>
    <style>
        ul#phoneList li{
            list-style-type:none;
            margin-left:-15px;
        }
        form, li{
            font-family:sans-serif;
            font-size:12px;
        }
    </style>
    <script type="text/javascript">
        function delNumber(id){
            c=confirm("Are you sure to remove this number from the list?");
            if(c){
                phoneList=document.getElementById("phoneList");
                newList=document.getElementById(id);
                phoneList.removeChild(newList);
               
                mForm=document.getElementById("mForm");
                hiddenInput=document.getElementById("hid_"+id);
                mForm.removeChild(hiddenInput);
               
            }
        }
       
        function addNumber(){
            newId=new Date().valueOf();
            mForm=document.getElementById("mForm");
            mNumber=document.getElementById("t_number").value;
            if(mNumber.length==0){
                alert("Type a phone number"); //use regex for more complex validation
            }else{
                document.getElementById("t_number").value='';
                newNumber=document.createElement("input");
                newNumber.type="hidden";
                newNumber.id="hid_"+newId;
                newNumber.name="number[]";
                newNumber.value=mNumber;
                mForm.appendChild(newNumber);
               
                phoneList=document.getElementById("phoneList");
                newList=document.createElement("li");
                newList.id=newId;
                newList.innerHTML="<a href=\"#\" title=\"Remove this number?\" onclick=\"delNumber('"+newId+"')\">(x)</a> - " + mNumber;
                phoneList.appendChild(newList);
            }
        }
    </script>
</head>

<body>
    <form action="<?php echo $_SERVER['PHP_SELF']?>" method="post" id="mForm">
        Message :<br />
        <textarea name="msg" style="width: 400px;height:100px"></textarea><br />
        Add Receiver : <br />
        <input type="text" id="t_number" style="width: 400px;" /><br />
        <input type="button" value="Add" onclick="addNumber()" />
        <input type="submit" value="Send" />
        <ul id="phoneList">
        </ul>
    </form>

</body>
</html>