PHP SQL SMS examples

The send_sms.php file can be used to send messages from a PHP script using the UCP-SQL application. Please create a php file and copy the following code into it.

send_sms.php

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
	<HEAD>
		<TITLE> SMS SENDER </TITLE>
	</HEAD>

	<BODY>

		<?php
		  $ow_database_type   = "MySql";
		  $ow_database_server = "localhost";
		  $ow_database_user   = "myuser";
		  $ow_database_pass   = "mypass";
		  $ow_database_name   = 'ozeki_ucp';
		
		
			$sms_sender='06305301904';
			$text=$_POST['text'];
			if (ereg("[']",$text)) {
			    $text=addslashes($_POST['text']);
			} # end if
			$mode=$_POST['mode'];
			$to=$_POST['to'];
			
			if ($mode=="send" && $text!="") {
			    $ow_mysql_link=mysql_pconnect($ow_database_server,$ow_database_user,$ow_database_pass) or die("database error");
			    mysql_select_db($ow_database_name);
			    mysql_query("insert into ozekismsout (sender, receiver, msg, status, datum, operator) values ('$sms_sender','$to','$text','send',now(),'ozeki')") or die("Insert Failed");
			   print "Sms insert was successful";
			} # end if
		?>
        <FORM ACTION='send_sms.php'  METHOD=POST NAME="sms_smsout" >
            <TABLE>
                <INPUT TYPE=HIDDEN NAME='mode' VALUE='send'>
                <TR>
                    <TD BGCOLOR=#CECECE COLSPAN=2>SMS OUT</TD>
                </TR>
                <TR>
                    <TD VALIGN=TOP> Recipient </TD>
                    <TD> <INPUT TYPE=TEXT NAME="to" VALUE="" SIZE=18> </TD>
                </TR>
                <TR>
                    <TD VALIGN=TOP> Text </TD>
                    <TD> <textarea rows=8 cols=30 wrap=virtual NAME="text"></textarea> </TD>
                </TR>
                <TR>
                    <TD> </TD>
                    <TD><INPUT TYPE=SUBMIT VALUE="OK"></TD>
                </TR>
            </TABLE>
        </FORM>
    </BODY>
</HTML>
	
Code 1 - This example code can be used to send messages with php

The list.php file can be used to print the incoming messages from a PHP script using the UCP-SQL application. Please create a php file and copy the following code into it.

list.php

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
    <HEAD>
        <TITLE> SMS IN </TITLE>
    </HEAD>
    <BODY>
		<?php
            $ow_database_type   = "MySql";
            $ow_database_server = "localhost";
            $ow_database_user   = "myuser";
            $ow_database_pass   = "mypass";
            $ow_database_name   = 'ozeki_ucp';
                $ow_mysql_link=mysql_pconnect($ow_database_server,$ow_database_user,$ow_database_pass) or die("database error");
                mysql_select_db($ow_database_name);


            echo "<table border>\n";
            echo "<tr>\n";
            echo "<td>\n";
            echo "DATUM\n";
            echo "</td>\n";
            echo "<td>\n";
            echo "SENDER\n";
            echo "</td>\n";
            echo "<td>\n";
            echo "TEXT\n";
            echo "</td>\n";
            echo "</tr>\n";

            $res=mysql_query("SELECT ozekismsin.sender,       ozekismsin.receiver,       ozekismsin.msg,       ozekismsin.senttime,       ozekismsin.receivedtime FROM ozekismsin order by ozekismsin.receivedtime desc limit 20");
            $cnti=mysql_num_rows($res);
            for ($i=0;$i<$cnti;$i++){
                $array=mysql_fetch_row($res);
                echo "<tr>\n";
                foreach ($array as $val) {
                    echo "<td>\n";
                    echo "$val\n";
                    echo "</td>\n";
                } # end foreach
                echo "</tr>\n";
            } # end for i
            echo "</table>\n";

        ?>
    </BODY>
</HTML>
	
Code 2 - This example code can be used to list the incoming messages

More information