PHP Self-training program to send SMS content

Source: Internet
Author: User

<!DOCTYPE HTML Public "-//W3C//DTD XHTML 1.0 transitional//en" "http://www.w3.org/TR/xhtml1/DTD/ Xhtml1-transitional.dtd "><HTMLxmlns= "http://www.w3.org/1999/xhtml"><Head><Metahttp-equiv= "Content-type"content= "text/html; charset=utf-8" /><title>Multi-user Message system--Write SMS</title><?php require Root_path. ' Includes/title.inc.php ';?><Scripttype= "Text/javascript"src= "Js/code.js"></Script><Scripttype= "Text/javascript"src= "Js/message.js"></Script></Head><Body><DivID= "message">    <H3>Write a text message</H3>    <formMethod= "POST"Action= "? Action=write">    <inputtype= "hidden"name= "Touser"value= "<?php echo $_html[' Touser ']?>" />    <DL>        <DD><inputtype= "text"value= "to:<?php echo $_html[' Touser ']?>"class= "text" /></DD>        <DD><textareaname= "Content"></textarea></DD>        <DD>Verification Code:<inputtype= "text"name= "Code"class= "Text Yzm"  />         <imgsrc= "code.php"ID= "Code" /> <inputtype= "Submit"class= "Submit"value= "Send SMS" /></DD>    </DL>    </form></Div></Body></HTML>

Content in a template page

<?PHPSession_Start();//defines a constant used to authorize the invocation of a file inside includesDefine(' IN_TG ',true);//defines a constant that specifies the contents of this pageDefine(' SCRIPT ', ' message ');//introduction of public filesrequire dirname(__file__).‘ /includes/common.inc.php ';//determine if you are logged inif(!isset($_cookie[' username ']) {_alert_close (' Please login first! ‘);}//Write a text messageif($_get[' Action ']== ' write '){    //to prevent malicious registration, cross-site attacks_check_code ($_post[' Code '],$_session[' Code ']); if(!!$_rows= _fetch_array ("Select Tg_uniqid from Tg_user WHERE tg_username= ' {$_cookie[' username ']} ' LIMIT 1 ")){    //Unique identifiers_uniqid ($_rows[' Tg_uniqid '],$_cookie[' Uniqid ']); includeRoot_path. ' Includes/register.func.php '; //Receive    $_clean=Array(); $_clean[' Touser ']=$_post[' Touser ']; $_clean[' Fromuser ']=$_cookie[' username ']; $_clean[' Content ']=_check_content ($_post[' Content ']); //Print_r ($_clean);    $_clean=_mysql_string ($_clean); //Write to Database_query ("INSERT into Tg_message (Tg_touser, Tg_fromuser, Tg_content, tg_date ) VALUES (' {$_clean[' Touser ']} ', ' {$_clean[' Fromuser ']} ', ' {$_clean[' content ']} ', now ()))"); //New Success    if(_affected_rows () ==1) {_close ();        _session_destroy (); _alert_back ("SMS sent Successfully"); }Else{_close ();        _session_destroy (); _alert_back ("SMS Send Failed"); }    }Else{_alert_close ("Illegal Login"); }}//Get Dataif(isset($_get[' ID '])) {    if(!!$_rows= _fetch_array ("Select Tg_username from Tg_user WHERE tg_id= ' {$_get[' ID ']} ' LIMIT 1 ")) {        $_html=Array(); $_html[' touser '] =$_rows[' Tg_username ']; $_html= _html ($_html); } Else{_alert_close (' There is no such user! ‘); }} Else{_alert_close (' Illegal operation! ‘);}?>

Display related actions (the database to create itself)

Related modified parameters, in Global environment variables (GLOBALS) and register.fnc.php

function_mysql_string ($_string) {    if(!GPC) {    //return mysql_real_escape_string ($_string);    if(Is_array($_string)){        foreach($_string  as $_key=$_value){            $_string[$_key]=_mysql_string ($_value); }    }Else{        return mysql_real_escape_string($_string); }    }    return $_string;}function_check_content ($_string){    if(Mb_strlen ($_string, ' Utf-8 ') <10| | Mb_strlen ($_string, ' Utf-8 ') >200) {_alert_back ("SMS content must not be less than 10 bits, or greater than 200 digits"); }    return $_string;}

Related to JS

Window.onload=function() {code (); varFm=document.getelementsbytagname (' form ') [0]; FM. onsubmit=function(){        //Verification Code Verification        if(fm.code.value.length!=4) {alert ("Verification code must be 4-bit"); FM. Code.Focus (); return false; }        if(fm.content.value.length<10| | fm.content.value.length>200) {alert ("SMS content must not be less than 10, more than 200!" "); FM. Content.Focus (); return false; }    };};

PHP Self-training program to send SMS content

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.