Jump to content

url input help


Kobi
Go to solution Solved by cyber_alchemist,

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.