Kobi Posted October 31, 2013 Share Posted October 31, 2013 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); } ?> Quote Link to comment Share on other sites More sharing options...
Solution cyber_alchemist Posted October 31, 2013 Solution Share Posted October 31, 2013 why don't you use $_POST ? $url = $_POST['website_name']; where the second file name is getload.php. Quote Link to comment Share on other sites More sharing options...
Kobi Posted October 31, 2013 Author Share Posted October 31, 2013 just did that, exactly what I wanted Thanks. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.