将html表单数据传递给php isDomainAvailible函数

时间:2015-12-09 21:44:54

标签: php html get

我正在开发一个网站状态系统,我有一个html表单,我用来将数据发送到PHP脚本但我遇到问题,我的html表单是使用GET的标准html表单。

这是我的PHP

      <?php
        $_GET['url']=$url;// my attempt...
        if (isDomainAvailible($url))//this is where the problem is
           {
           echo "Good news! Its online and responding as it should!";
          }
          else
            {
           echo "Hmm? you sure that is a real website?";
            }

            //returns true, if domain is availible, false if not
           function isDomainAvailible($domain)
           {
           //check, if a valid url is provided
           if(!filter_var($domain, FILTER_VALIDATE_URL))
           {
                   return false;
           }

           //initialize curl
           $curlInit = curl_init($domain);
           curl_setopt($curlInit,CURLOPT_CONNECTTIMEOUT,10);
           curl_setopt($curlInit,CURLOPT_HEADER,true);
           curl_setopt($curlInit,CURLOPT_NOBODY,true);
           curl_setopt($curlInit,CURLOPT_RETURNTRANSFER,true);

           //get answer
           $response = curl_exec($curlInit);

           curl_close($curlInit);

           if ($response) return true;

           return false;
   }
  ?>

1 个答案:

答案 0 :(得分:0)

您在分配前检查该值:

{{1}}