Advertisement
Guest User

Untitled

a guest
Apr 18th, 2016
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. <?php
  2.  
  3. session_start();
  4.  
  5. $servername = "**.**.***.***";
  6. $username = "******";
  7. $password = "*******";
  8. $dbname = "**********";
  9.  
  10. $conn = new mysql($servername, $username, $password, $dbname);
  11. if ($conn->connect_error) {
  12. die("Connection failed: " . $conn->connect_error);
  13. }
  14.  
  15. $phonenumber= $_POST['phonenumber'];
  16.  
  17. $sql = "SELECT COUNT(*) FROM AccountForm WHERE phonenumber= '{$_POST['phonenumber']}'";
  18. $result = $conn->query($sql);
  19. if (mysql_result($sql_result, 0)<1)
  20. {
  21. die("<BR>Unknown user; account not found");
  22. }
  23. else {
  24. echo "Success!";
  25. }
  26.  
  27. while($row = mysql_fetch_assoc($result)) {
  28. $phonenumber = $row['phonenumber'];
  29. }
  30.  
  31. $result = mysql_query("SELECT * FROM AccountForm WHERE phonenumber = '$phonenumber' LIMIT 1");
  32.  
  33. if(mysql_num_rows($result) > 0){
  34. $row = mysql_fetch_array($result, MYSQL_ASSOC);
  35. $firstname = $row["firstname"];
  36. echo "<BR>Your pizza will be here in 15 minutes, ";
  37. echo $firstname;
  38. }else{
  39. echo 'Unknown user; account not found';
  40. }
  41.  
  42.  
  43. function pizza2(){
  44. $response = new Services_Twilio_Twiml();
  45. $response->sms("Your " . $row["size2"]. " " . $row["topping2"]. " pizza has been ordered, " . $row["firstname"]. " " . $row["lastname"]. ". It will be delivered to " . $row["physicaladdress"]. " " . $row["city"]. " " . $row["state"]. " in 10 minutes");
  46. echo $response;
  47. }
  48.  
  49. $body = $_REQUEST['Body'];
  50.  
  51. $result = preg_replace("/[^A-Za-z0-9]/u", " ", $body);
  52. $result = trim($result);
  53. $result = strtolower($result);
  54.  
  55. switch ($result) {
  56. case 'pizza1':
  57. pizza1();
  58. break;
  59. case 'pizza2':
  60. pizza2();
  61. break;
  62. }
  63.  
  64. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement