title: PHP connect to Telnet server
body: <p>I need to connect to a Server and send Commands VIA Telnet but am having a bit of trouble finding out how to connect with authorization.</p>
  
  <p>I have used the following script to connect, but I still need to input username and password to gain access.</p>
  
  <pre><code>&lt;?php
  
            $host="xxxxxxxxxxx"; 
      $port = xxxxxxxxxx; // open a client connection 
      $fp = fsockopen ($host, $port, $errno, $errstr); 
      if (!$fp) { 
      $result = "Error: could not open socket connection"; 
      } 
      else { // get the welcome message fgets ($fp, 1024); // write the user string to the socket 
      fputs($fp, $message); // get the result $result .= fgets ($fp, 1024); // close the connection
      fputs ($fp, "END");
      fclose ($fp); // trim the result and remove the starting ?
      $result = trim($result);
      $result = substr($result, 2); // now print it to the browser 
      } ?&gt; 
      Server said: &lt;? echo $result; ?&gt;
  
  
      ?&gt;
  </code></pre>
  
  <p>Ive been looking around, even on the PHP documentation but don't see a way to use password and username. </p>
  
  <p>Do I have to use POST data to post my username and password?</p>