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

Recommended Answers

All 3 Replies

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.

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).

commented: This has no connection with the topic. +0
commented: Not really related, though I can see how you thought it might be. The question involved SMS shortcode not MySQL shortcode. Please read the post. +0
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.