Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > PHP > PHP Forum > รบกวนช่วยแทรกโค้ดเหล่านี้ให้ส่งSMS แล้วลงไปในฐานข้อมูล MySQL ให้ได้ทีครับ ขอร้องนะครับ ช่วยหน่อยน้า



 

รบกวนช่วยแทรกโค้ดเหล่านี้ให้ส่งSMS แล้วลงไปในฐานข้อมูล MySQL ให้ได้ทีครับ ขอร้องนะครับ ช่วยหน่อยน้า

 



Topic : 066615



โพสกระทู้ ( 11 )
บทความ ( 0 )



สถานะออฟไลน์




คือผมทำหน้าเว็บโดยใช้ PHP เชื่อมต่อฐานข้อมูล Mysql อยู่ครับ แล้วผมต้องการสร้างหน้าเว็บPHPในการส่ง SMS ผ่านฟอร์ม
โดยผมได้ใช้โปรแกรม Ozeki Server เพื่อเป็นตัวกลางในการส่งSMS ที่ได้เชื่อมต่อกับโทรศัพท์มือถือของผม ซึ่งเปรียบเสมือนเบอร์โทรผมเป็นผู้ส่งไปยังผู้รับSMS อะครับ

โดย sendsms_form.html จะเป็นหน้าฟอร์มสำหรับรับค่าที่ได้กรอกลงไป แล้วนำค่านั้นส่งไปยัง sendsms.php เพื่อส่ง SMS ต่อไป
โค้ดส่งSMS สองตัวแรกแล้วทำการส่งSMS ซึ่งไม่ได้เชื่อมต่อกับฐานข้อมูลแต่อย่างใด

sendsms_form.html
<html>
<form method=post action='sendsms.php'> 
<table border=0>
<tr> 
<td>Sender</td><td><input type='text' name='sender'></td> 
</tr>
<tr> 
<td>Recepient</td><td><input type='text' name='recepient'></td> 
</tr>
<tr> 
<td>Message</td><td><input type='text' name='message'</td> 
</tr>
<tr> 
<td colspan=2><input type=submit name=submit value=Send> 
</form>
</tr>
</table>
</form> 
</html>


sendsms.php เป็นคำสั่งที่ใช้ในการเชื่อมต่อระหว่างเว็บกับตัวโปรแกรมเพื่อส่งSMS ไปให้ผู้รับที่ระบุในฟอร์มของsendsms_form.html
sendsms.php
<?php 
header('Content-type: text/html; charset=utf-8'); 
?>
<?php
if ($submit=="Send")
{
$url='http://127.0.0.1:9333?';   	     // ที่อยู่เว็บของตัวโปรแกรม Ozeki Server
$url.="action=sendMessage";
$url.="&login=admin";	      //  ชื่อผู้ใช้งานของตัวโปรแกรม Ozeki server 
$url.="&password=abc123"; 	      // รหัสของตัวโปรแกรม Ozeki Server 
$url.="&recepient=".urlencode($recepient);
$url.="&messageData=".urlencode($message); 
file($url);
}
{
  echo("<script> alert(' !!!!  ส่งข้อความเรียบร้อยแล้วครับ !!!! '); window.location='sendsms_form.html';</script>");
 exit();
 }
?> 


ส่วนสองโค้ดคือ sqlsmshandling_functions.php กับ sqlsmshandling.php เมื่อกดส่งไปแล้วข้อความที่ส่งสามารถนำมาลงในฐานข้อมูล Mysql ได้แต่ไม่สามารถส่ง SMS ไปยังมือถือได้
sqlsmshandling.php
<html>
<head>
<?php
    include_once ("sqlsmshandling_functions.php");
?>
    <title>SMS sending by PHP5 and MySQL</title>
</head>
<body>
<form action="" method="post">
    <table border="0" align="center">
        <tr>
            <td colspan="2" align="center">
                <font style="font-weight: bold; font-size: 16px;">เขียนข้อความ</font>
                <br /><br />
            </td>
        </tr>
        <tr>
            <td valign="top">เบอร์ผู้รับ : </td>
            <td>
                <textarea name="textAreaRecipient" cols="40" rows="2"><?php  echo ((isset($_POST["textAreaRecipient"])) ? ($_POST

["textAreaRecipient"]) : ("")); ?></textarea>
            </td>
        </tr>
        <tr>
            <td valign="top">ข้อความ : </td>
            <td>
                <textarea name="textAreaMessage" cols="40" rows="10"><?php  echo ((isset($_POST["textAreaMessage"])) ? ($_POST

["textAreaMessage"]) : ("")); ?></textarea>
            </td>
        </tr>
        <tr>
            <td colspan="2" align="center">
                <input type="submit" value="Send">
            </td>
        </tr>
        <tr><td colspan='2' align='center'>
        <?php
        if (isset($_POST["textAreaRecipient"]) && $_POST["textAreaRecipient"] == "")
        {
            echo "<font style=\"color: red; font-weight: bold;\">Recipient field mustn't be empty!</font>";
        }
        else if (isset($_POST["textAreaRecipient"]) && $_POST["textAreaRecipient"] != "")
        {
            try
            {
                connectToDatabase();
                if (insertMessage ($_POST["textAreaRecipient"], "SMS:TEXT", $_POST["textAreaMessage"]))
				
                {
                    echo "<font style=\"color: red; font-weight: bold;\">Insert was successful!</font>";
                }
                closeConnection ();
            }
            catch (Exception $exc)
            {
                echo "Error: " . $exc->getMessage();
            }
        }
        ?>
        </td></tr>
    </table>
</form>


sqlsmshandling_functions.php
<?php
    $connection = null; //a global variable. From function we access it: $GLOBALS["connection"]
    
    function connectToDatabase()
    {
        $serverName = "127.0.0.1";
        $userName = "root";
        $password = "1234";
        $databaseName = "sms";
        
        //create connection and select database by given data
        $GLOBALS["connection"] = mysql_connect($serverName, $userName, $password);
        if ($GLOBALS["connection"] == null)
        {
            echo mysql_error() . "<br>";
            return false;
        }
            
        try
        {
            mysql_select_db($databaseName);
        }
        catch (Exception $exc)
        {
            echo (mysql_error() . "<br>");
            return false;
        }
        
        return true;
    }
    
    function closeConnection ()
    {
        try
        {
            mysql_close($GLOBALS["connection"]);
        }
        catch (Exception $exc)
        {
            //echo ($exc->getMessage() . "<br>");
        }
    }
	
    
    function insertMessage ($recipient, $messageType, $messageText)
    {
        $query = "insert into ozekimessageout (receiver,msgtype,msg,status) ";
        $query .= "values ('" . $recipient . "', '" . $messageType . "', '" . $messageText . "', 'send');";
		mysql_query("SET NAMES UTF8");
        $result = mysql_query ($query);
        if (!$result)
        {
            echo (mysql_error() . "<br>");
            return false;
        }
        
        return true;
    }
    
    function showOutgoingMessagesInTable()
    {
        $query = "select id,sender,receiver,senttime,receivedtime,operator,status,msgtype,msg from ozekimessageout;";
		mysql_query("SET NAMES UTF8");
        $result = mysql_query ($query);
        if (!$result)
        {
            echo (mysql_error() . "<br>");
            return false;
        }
        
        try
        {
            echo "<table border='1'>";
            echo "<tr><td>ID</td><td>Sender</td><td>Receiver</td><td>Sent time</td><td>Received time</td><td>Operator</td>";
            echo "<td>Status</td><td>Message type</td><td>Message text</td></tr>";
            while ($row = mysql_fetch_assoc($result))
            {
                echo "<tr>";
                
                echo "<td>" . $row["id"] . "</td>";
                echo "<td>" . $row["sender"] . "</td>";
                echo "<td>" . $row["receiver"] . "</td>";
                echo "<td>" . $row["senttime"] . "</td>";
                echo "<td>" . $row["receivedtime"] . "</td>";
                echo "<td>" . $row["operator"] . "</td>";
                echo "<td>" . $row["status"] . "</td>";
                echo "<td>" . $row["msgtype"] . "</td>";
                echo "<td>" . $row["msg"] . "</td>";
                
                echo "</tr>";
            }
            echo "</table>";
            mysql_free_result($result);
        }
        catch (Exception $exc)
        {
            echo (mysql_error() . "<br>");
            return false;
        }
        
        return true;
    }
    
    function showIncomingMessagesInTable()
    {
        $query = "select id,sender,receiver,senttime,receivedtime,operator,msgtype,msg from ozekimessagein;";
		mysql_query("SET NAMES UTF8");
        $result = mysql_query ($query);
        if (!$result)
        {
            echo (mysql_error() . "<br>");
            return false;
        }
        
        try
        {
            echo "<table border='1'>";
            echo "<tr><td>ID</td><td>Sender</td><td>Receiver</td><td>Sent time</td><td>Received time</td><td>Operator</td>";
            echo "<td>Message type</td><td>Message text</td></tr>";
            while ($row = mysql_fetch_assoc($result))
            {
                echo "<tr>";
                
                echo "<td>" . $row["id"] . "</td>";
                echo "<td>" . $row["sender"] . "</td>";
                echo "<td>" . $row["receiver"] . "</td>";
                echo "<td>" . $row["senttime"] . "</td>";
                echo "<td>" . $row["receivedtime"] . "</td>";
                echo "<td>" . $row["operator"] . "</td>";
                echo "<td>" . $row["msgtype"] . "</td>";
                echo "<td>" . $row["msg"] . "</td>";
                
                echo "</tr>";
            }
            echo "</table>";
            mysql_free_result($result);
        }
        catch (Exception $exc)
        {
            echo (mysql_error() . "<br>");
            return false;
        }
        
        return true;
    }
?>


สรุปสิ่งที่ต้องการให้ช่วยนะครับ
1. ต้องการให้นำโค้ด sendsms_form.html กับ sendsms.php ซึ่งสามารถส่งSMS ไปยังมือถือได้ แทรกเข้าไปอยู่ในโค้ด sqlsmshandling.php กับ sqlsmshandling_functions.php ซึ่งสามารถนำข้อความที่กรอกลงในฟอร์มบันทึกลงในฐานข้อมูล Mysql ได้ แต่ไม่สามารถส่งSMS ไปยังมือถือได้ จึงอยากให้ช่วยแก้ไขโค้ดเพื่อให้สามารถส่งSMS และทำการบันทึกลงในฐานข้อมูลได้ด้วยอะครับ

2. ต้องการให้แก้ไขโค้ด sendsms.php ให้สามารถส่งSMS ไปยังมือถือเป็นภาษาไทยได้ ซึ่งในที่นี้ยังส่งภาษาไทยไม่ได้ มันจะแสดงผลเป็นภาษาต่างดาวอะครับ

ขอบคุณมากๆครับผม ต้องการความช่วยเหลือจิงๆครับ



Tag : PHP, MySQL, JavaScript







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2011-09-15 21:51:10 By : rockdie View : 2526 Reply : 7
 

 

No. 1



โพสกระทู้ ( 74,058 )
บทความ ( 838 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Twitter Facebook

Code (PHP)
file($url);
}
{
  echo("<script> alert(' !!!!  ส่งข้อความเรียบร้อยแล้วครับ !!!! '); window.location='sendsms_form.html';</script>");
 exit();
 }


แทรก function สำหรับ insert ลงใน MySQL ตรงเงื่อนไขนี้ก็ได้ครับ






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-09-16 09:10:05 By : webmaster
 


 

No. 2



โพสกระทู้ ( 11,835 )
บทความ ( 10 )

สมาชิกที่ใส่เสื้อไทยครีเอท Hall of Fame 2012

สถานะออฟไลน์


Code
function insertMessage ($recipient, $messageType, $messageText)
{
$query = "insert into ozekimessageout (receiver,msgtype,msg,status) ";
$query .= "values ('" . $recipient . "', '" . $messageType . "', '" . $messageText . "', 'send');";
mysql_query("SET NAMES UTF8");
$result = mysql_query ($query);
if (!$result)
{
echo (mysql_error() . "<br>");
return false;
}else{
$url='http://127.0.0.1:9333?'; // ที่อยู่เว็บของตัวโปรแกรม Ozeki Server
$url.="action=sendMessage";
$url.="&login=admin"; // ชื่อผู้ใช้งานของตัวโปรแกรม Ozeki server
$url.="&password=abc123"; // รหัสของตัวโปรแกรม Ozeki Server
$url.="&recepient=".urlencode($recepient);
$url.="&messageData=".urlencode($messageText);
}


return true;
}


ใส่เข้าไปแบบนี้ดื้อๆ เลยครับ หลังจากเพิ่มลงดีบีแล้ว
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-09-16 09:14:04 By : ikikkok
 

 

No. 3



โพสกระทู้ ( 11 )
บทความ ( 0 )



สถานะออฟไลน์


ขอบคุณพี่ๆทั้งสองครับ ถ้าไม่ได้ยังไงเด๋วมาแจ้งอีกนะคร้าบบบ ^^
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-09-16 13:49:57 By : rockdie
 


 

No. 4



โพสกระทู้ ( 11 )
บทความ ( 0 )



สถานะออฟไลน์


ยังไม่ได้เลยอะครับ ช่วยเรียบเรียงโค้ดให้นิดนึงนะครับ พี่ๆ ผมเพิ่งหัดอะครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-09-16 20:37:02 By : rockdie
 


 

No. 5



โพสกระทู้ ( 11,835 )
บทความ ( 10 )

สมาชิกที่ใส่เสื้อไทยครีเอท Hall of Fame 2012

สถานะออฟไลน์


insert ลงไหม ส่งได้หรือเปล่า
ตกลงส่งภาษาไทยไม่ได้อย่างเดียว หรือว่ายังไง
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-09-17 01:27:05 By : ikikkok
 


 

No. 6



โพสกระทู้ ( 439 )
บทความ ( 0 )



สถานะออฟไลน์


จากกระทู้นี้ ผมของ ข้อมูล ตาราง และข้อมูลที่อยู่ในฟิวล์ ตัวอย่าง 4-5 ตัวอย่าง ขอคำแนะนำหน่อย ครับบบ

และ (
$url='http://127.0.0.1:9333?'; // ที่อยู่เว็บของตัวโปรแกรม Ozeki Server
$url.="action=sendMessage";
$url.="&login=admin"; // ชื่อผู้ใช้งานของตัวโปรแกรม Ozeki server
$url.="&password=abc123"; // รหัสของตัวโปรแกรม Ozeki Server
$url.="&recepient=".urlencode($recepient);
$url.="&messageData=".urlencode($messageText);
)


$url='http://127.0.0.1:9333?';// ตัวเลขสีแดง อ้างอิ้งจากจุดไหนครับ
$url.="&login=admin";//แล้ว login ตัวนี้ ต้องไป กำหนด ในโปรแกรม Ozeki ใช่ไหมครับ แต่ ผมติดตั้งแล้ว แต่เปิดไม่ได้ ครับ
$url.="&password=abc123";


ประวัติการแก้ไข
2018-01-23 10:20:46
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2018-01-23 10:13:41 By : baby137
 


 

No. 7



โพสกระทู้ ( 4,169 )
บทความ ( 7 )

Hall of Fame 2012

สถานะออฟไลน์


ตอบความคิดเห็นที่ : 6 เขียนโดย : baby137 เมื่อวันที่ 2018-01-23 10:13:41
รายละเอียดของการตอบ ::
ตั้งกระทู้ใหม่ครับ

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2018-01-23 10:49:05 By : dudesaranyu
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : รบกวนช่วยแทรกโค้ดเหล่านี้ให้ส่งSMS แล้วลงไปในฐานข้อมูล MySQL ให้ได้ทีครับ ขอร้องนะครับ ช่วยหน่อยน้า
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 05
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่