title: I want to make a telegram bot with php keyboards button not work properly
body: <p>i want to make a telegram bot with php that ask some question one by one (keyboard buttons) and store details in object and finally answer something is exists or not!</p>
  
  <p>i wrote this code</p>
  
  <pre><code>&lt;?php
      require_once ("iphone_class.php");
  
      $message = file_get_contents("php://input");
      $result = json_decode($message, true);
  
      file_put_contents('test.txt', $result);
  
      $token = "255676049:AAEv9GbV95Xg2UmzZR4D-0kXbIj73NKnl4o";
      $base_url = "https://api.telegram.org/bot{$token}/SendMessage?chat_id=";
      $chat_id = $result['message']['chat']['id'];
      $message_from_user = $result["message"]["text"];
  
      function AddtoKeyboard($names)
      {
          $ar = array(
              'keyboard' =&gt; array(),
          );
          foreach ($names as $name) {
              $ar2 = array($name);
              array_push($ar["keyboard"], $ar2);
  
          }
          return $ar;
      }
  
      function get_new_message(){
          $message = file_get_contents("php://input");
          $result = json_decode($message, true);
          $message_from_user = $result["message"]["text"];
          return $message_from_user;
      }
  
      if ($message_from_user == "موبایل") {
  
          $m = array("صفحه ی اصلی", "اندرویدی", "اپل");
          $keyb = json_encode(AddtoKeyboard($m));
          $rep = file_get_contents($base_url . $chat_id . "&amp;text=" . urlencode("لطفا نوع موبایل مورد نظر را انتخاب کنید: ")
              . "&amp;reply_markup=" . $keyb);
  
          $message_from_user = get_new_message();
          file_get_contents($base_url . $chat_id . "&amp;text=" . urlencode($message_from_user));
  
          if ($message_from_user == "اپل") {
  
              $iphone = new Iphone();
  
              $m = array("صفحه ی اصلی", "5", "5c", "5s", "se", "6", "6 plus", "6s", "6s plus");
              $keyb = json_encode(AddtoKeyboard($m));
              $rep = file_get_contents($base_url . $chat_id . "&amp;text=" . urlencode("لطفا مدل موبایل مورد نظر را انتخاب کنید: ")
                  . "&amp;reply_markup=" . $keyb);
              $message_from_user = get_new_message();
              $iphone-&gt;setModel($message_from_user);
  
              $m = array("صفحه ی اصلی", "16", "64", "128", "256");
              $keyb = json_encode(AddtoKeyboard($m));
              $rep = file_get_contents($base_url . $chat_id . "&amp;text=" . urlencode("لطفا ظرفیت موبایل مورد نظر را انتخاب کنید: ")
                  . "&amp;reply_markup=" . $keyb);
              $message_from_user = get_new_message();
              $iphone-&gt;setCapacity($message_from_user);
  
              $m = array("صفحه ی اصلی", "silver", "gray", "gold", "roseGold");
              $keyb = json_encode(AddtoKeyboard($m));
              $rep = file_get_contents($base_url . $chat_id . "&amp;text=" . urlencode("لطفا رنگ موبایل مورد نظر را انتخاب کنید: ")
                  . "&amp;reply_markup=" . $keyb);
              $message_from_user = get_new_message();
              $iphone-&gt;setColor($message_from_user);
  
              //TODO check ba database va message dadan quanity
  
          }else if ($message_from_user == "اندروید"){
  
          }
  
  
      } else if ($message_from_user == "لپ تاپ") {
  
  
      } else if ($message_from_user == "تبلت") {
  
          $text = "ipad";
  
      } else if ($message_from_user == "صفحه ی اصلی") {
  
          $m = array("موبایل", "تبلت", "لپ تاپ");
          $keyb = json_encode(AddtoKeyboard($m));
          $rep = file_get_contents($base_url . $chat_id . "&amp;text=" . urlencode("صفحه ی اصلی") . "&amp;reply_markup=" . $keyb);
  
      } else {
  
          $text = "hichkodoom";
          file_get_contents($base_url . $chat_id . "&amp;text=" . urlencode($text));
  
      }
  
      ?&gt;
  </code></pre>
  
  <p>but after </p>
  
  <pre><code>if ($message_from_user == "موبایل") {
  
          $m = array("صفحه ی اصلی", "اندرویدی", "اپل");
          $keyb = json_encode(AddtoKeyboard($m));
          $rep = file_get_contents($base_url . $chat_id . "&amp;text=" . urlencode("لطفا نوع موبایل مورد نظر را انتخاب کنید: ")
              . "&amp;reply_markup=" . $keyb);
  
          $message_from_user = get_new_message();
  </code></pre>
  
  <p>message wont update to last answer and my php file runs from begin and i lost my object iphone!</p>