http_post() variables to php script from SMS message but only append data to text file if certain variable (telephone number) equals a known

Posted by user1592162 on Stack Overflow See other posts from Stack Overflow or by user1592162
Published on 2012-11-23T22:33:21Z Indexed on 2012/11/23 23:04 UTC
Read the original article Hit count: 278

Filed under:
|
|
|
|

All, I have an SMS gateway application running on my server that passes incoming SMS messages to a php script. That script writes the data to a text file. Certain aspects of the message can be extracted as variables - for example: Message content: $msgdata Sender: $originator Time: $receivedtime etc... Using the script below I can easily write the message to a text file but it will write the data of every SMS that comes in. I only want to write to a text file if the $originator variable is a certain telephone number (e.g 07123456321)

$date = date("d.m.Y H:i:s");
$msgdata = $_REQUEST["msgdata"]; 
$myFile3 = "test.txt";
$fh = fopen($myFile3, 'a') or die("can't open file");
$stringData3 = "$date - $msgdata\n";
fwrite($fh, $stringData3);
fclose($fh);

Your assistance is bery much appreciated. Many thanks in advance.

© Stack Overflow or respective owner

Related posts about php

Related posts about file