Advertisement
Guest User

Untitled

a guest
Apr 17th, 2014
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.20 KB | None | 0 0
  1. <?php
  2.  
  3. if ($_SERVER['REQUEST_METHOD']!='POST')
  4. {
  5.   echo 'This script is not supposed to be viewed in a browser!';
  6.   exit;
  7. }
  8.  
  9. // Connecting to the database.
  10. // Change the parameter values to the actual ones
  11. $con = new mysql_connect('localhost','nrtx_sms','13101991as','nrtx_sms');
  12.  
  13.  
  14. $insert_sms_success = FALSE;
  15.  
  16. if (mysql_connect_errno()==0)
  17. { // if successfully connected
  18.  
  19.   $sent_dt=$_POST['scts'];
  20.   // important: escape string values
  21.   $txt=mysql_real_escape_string($con, $_POST['text']);
  22.   $snd=mysql_real_escape_string($con, $_POST['sender']);
  23.  
  24.   // creating an sql statement to insert the message into the SMS_IN table
  25.   $sql="INSERT INTO SMS_IN(sms_text,sender_number,sent_dt) VALUES ('$txt','$snd','$sent_dt')";
  26.   // executing the sql statement
  27.   $insert_sms_success = mysql_query($con,$sql);
  28.  
  29.   // closing the connection
  30.   mysqli_close($con);
  31. }
  32.  
  33. if ($insert_sms_success)
  34. {
  35.   // if we have succeeded to insert sms into the database
  36. }
  37. else
  38. {  
  39.   // if we have failed to insert sms into the database.  
  40.   // Here you can do something upon failure to insert sms into the database.
  41.   // For example, let SMS Enabler know an error has occured
  42.   http_response_code(500);
  43. }
  44.  
  45. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement