2015-12-09 35 views
1

我正在开发一个网站状态系统,我有一个用于将数据发送到php脚本的html表单,但我有问题,我的html表单是一个标准的html表单得到。将html表单数据传递给php isDomainAvailible函数

这是我的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; 
    } 
    ?> 
+0

问题是什么?你说你多次遇到问题,但从来没有说过是什么导致你认为你有问题? –

+0

对不起,我无法将数据从表单发送到php脚本,它默认回显“嗯?你确定这是一个真正的网站?”; ,因为该函数没有数据。 –

+2

不应该是相反的方式吗? '$ url = $ _ GET ['url'];'while isset isset()'。 –

回答

0

要检查其分配给前值:

$url = $_GET['url'];// my attempt... 
     if (isDomainAvailible($url))//this is where the problem is 
      { 
+0

非常感谢您的工作! –