2015-12-09 75 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

非常感謝您的工作! –