0

I have created script for lk domain search.

this is the code

<form action="" method="GET">
    <input type="text" name="dm" placeholder="tx">
</form>

<?php 

if (isset($_GET["dm"])) {

    $domain = $_GET["dm"];

    $res = file_get_contents("https://www.domains.lk/domainsearch/doDomainSearch?domainname=$domain");

    echo $domain;
}

?>

<script type="text/javascript">

    var data = '<?php echo $res ?>';

    document.write(data);

</script>

var data will show in local host. but i have hosted it in my server then result will not show.

this is server hosted file http://vishmaloke.com/dm/ser.php

Shenald
  • 143
  • 1
  • 12
  • Make sure you have the extension `php_openssl.dll` enabled in your server's `php.ini` file. You will have to restart your web server (Apache/Nginx) afterwards. – Gary Thomas May 25 '18 at 06:15
  • Look at the error logs. There must be a description of what is going on. – Pyton May 25 '18 at 06:15

1 Answers1

0

SOLUTION #1

There is PHP setting by name allow_url_fopen. This must be enable to get content from remote url. You can do it via .htaccess file.

Put following line in an .htaccess file in the directory you want the setting to be enabled:

php_value allow_url_fopen On

Note: This above setting will apply only into same directory where .htaccess file placed.


SOLUTION #2

Alternatively you can update php.ini

PHP.INI UPDATE

add following line to php.ini

allow_url_fopen = On;

SOLUTION 3

It is recommended to use curl instead of file_get_contents

CURL UPDATE

if (isset($_GET["dm"]))
{

    $domain = $_GET["dm"];

    // curl
    $curl_handle=curl_init();
    curl_setopt($curl_handle, CURLOPT_URL,"https://www.domains.lk/domainsearch/doDomainSearch?domainname=$domain");
    curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 2);
    curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
    $res = curl_exec($curl_handle);
    curl_close($curl_handle);


    echo $domain;
}
Muhammad Hassaan
  • 7,296
  • 6
  • 30
  • 50