954,587 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

PHP MySQL ShortCode System.

Hi Everyone.

Could anyone give me some pointers in creating a PHP, MySQL ShortCode system.
I want to create a system where a user can SMS a keyword to a short code SMS number.

Example: SMS pizza to 33333.

Then the server checks pizza in MySQL DB and replies with top 5 pizza places.

Regards

LRNPHP
Junior Poster in Training
62 posts since Jul 2010
Reputation Points: 10
Solved Threads: 1
 

Well you'll need to find a way to get the short code SMS to communicate with your PHP script. I have no idea how to do this. When it comes to the PHP, it seems easy enough.

switch(strtolower($_GET['command'])) {
    case 'pizza':
        $r = mysql_query("SELECT * FROM pizza ORDER BY popularity DESC LIMIT 5");
        if(mysql_num_rows($r) != 0) {
            while($arr = mysql_fetch_array($r)) { echo $arr['name']; }
        } else { echo "No pizzas found. Sry!"; }
        break;
}

This would work assuming you have already connected to your database and your table structure is similar to my little demo. You would also need to have texts to the number routed to your script, assuming the command parameter contains the contents of the text and the stdout is returned to the sender of the text message.

FlashCreations
Posting Whiz
395 posts since Sep 2008
Reputation Points: 47
Solved Threads: 47
 

To get from SMS to your server you will need to use an SMS gateway service (and you will need to pay for it). That will allow you to go in both directions.
One example: ClickaTell

At no cost, you can go from the server to SMS if you have the phone number and know the cell phone provider (and the SMS email address format for that specific provider).

chrishea
Nearly a Posting Virtuoso
1,428 posts since Sep 2008
Reputation Points: 210
Solved Threads: 230
 
MooGeek
Posting Whiz
355 posts since Mar 2009
Reputation Points: 26
Solved Threads: 33
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You