Jump to content

Basic Curl Question


Drezard

Recommended Posts

I work as a Network Engineer and we get a number of customers who forgot their modem passwords.

 

So, Im trying to write a Curl script (and slowly learning Curl as well). Ive written a test script, which is here:

 

<?php

// curl.php

$curl = curl_init();

curl_setopt($curl, CURLOPT_URL, 'http://www.rootedbox.info/curl/http-protocol/protected/');

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

curl_setopt($curl, CURLOPT_USERPWD, 'admin:password');

$output = curl_exec($curl);

$info = curl_getinfo($curl);

if ($info['http_code'] == 401) {
        echo "Password is incorrect";
}
else {
        echo "Password is: password";
}

curl_close($curl);

?>

 

How do I make it so that it doesn't display the page returned....

 

So currently, when I run this script, it displays the "401 - Error" and then my "The password is...." bit. I want it ONLY to display the "The password is..." bit.

 

Daniel

Link to comment
https://forums.phpfreaks.com/topic/137491-basic-curl-question/
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.