How change the value of variable in api url dynamically using HTML form

陌路散爱 提交于 2020-08-08 05:16:27

问题


I am getting the value of $mc_out with the below code:

    <input type="text" id="input"><?php $mc_out = '<span style="display:none;">oninput:</span> <span 
    id="result"></span>' ;?>

   <script>
  input.oninput = function() {
   result.innerHTML = input.value;
   };
  </script>

Now i am using this variable $mc_out in my api to get value dynamically. $mc_out value is changing everytime i change the value in form above but its not working in the below api without refresh. And once the page refreshed then $mc_out will become empty unless i enter the value again in the form.

                $curl = curl_init();

                curl_setopt_array($curl, array(
                  CURLOPT_URL => "http://test-api-dev.testurl.org/in_school/$mc_out",
                  CURLOPT_RETURNTRANSFER => true,
                  CURLOPT_ENCODING => "",
                  CURLOPT_MAXREDIRS => 10,
                  CURLOPT_TIMEOUT => 0,
                  CURLOPT_FOLLOWLOCATION => true,
                  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
                  CURLOPT_CUSTOMREQUEST => "GET",
                  CURLOPT_HTTPHEADER => array(
                    "Authorization: Bearer $final_token"
                  ),
                ));

                $response = curl_exec($curl);
                $data = json_decode($response, true);
                print_r($data);

please help me with this problem.

来源:https://stackoverflow.com/questions/63009083/how-change-the-value-of-variable-in-api-url-dynamically-using-html-form

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!