Jump to content

url input help


Kobi

Recommended Posts

Hi, I want to generate an input url from a user to check website download time. can someone explain how to pass the input to the $url function.

Thanks.

 

first file:

---------------------------------------------------------------------------

 

<html>
        <head>
                <title>check website</title>
        </head>
<body>
 
<div id="main">
 
<form action="getload.php" method="post">
<p>Website name:
        <input type="text" name="website_name" value="" />
</p>
<input type="submit" value="check website" />
</form>
 
 
</div>
 
</body>
</html>
 
 
second file:
---------------------------------------------------------------------------
 
<?php error_reporting(E_ALL | E_STRICT);
 
// Initialize cURL with given url
$url = ('http://some-web-page.com');
$ch = curl_init($url);
 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
 
set_time_limit(65);
 
$execute = curl_exec($ch);
$info = curl_getinfo($ch);
 
// Time spent downloading, I think
$time = $info['total_time']
      - $info['namelookup_time']
      - $info['connect_time']
      - $info['pretransfer_time']
      - $info['starttransfer_time']
      - $info['redirect_time'];
 
 
// Echo friendly messages
header('Content-Type: text/plain');
printf("Downloaded %d bytes in %0.4f seconds.\n", $info['size_download'], $time);
printf("Which is %0.4f mbps\n", $info['size_download'] * 8 / $time / 1024 / 1024);
printf("CURL said %0.4f mbps\n", $info['speed_download'] * 8 / 1024 / 1024);
 
echo "\n\ncurl_getinfo() said:\n", str_repeat('-', 31 + strlen($url)), "\n";
foreach ($info as $label => $value)
{
        printf("%-30s %s\n", $label, $value);
}
?>

 

Link to comment
https://forums.phpfreaks.com/topic/283469-url-input-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.