ftp_login() function in PHP


The ftp_login() function allows you to log in to the FTP connection.

Syntax

ftp_login(con,user_name,password);

Parameters

  • con − The FTP connection

  • user_name − The user name to log in

  • password − The password to login

Return

The ftp_login() function returns TRUE on success or FALSE and warning on failure.

Example

The following is an example −

<?php
   $ftp_server="192.168.0.4";
   $ftp_user="amit";
   $ftp_pass="tywg61gh";
   $con = ftp_connect($ftp_server) or die("Could not connect to $ftp_server");
   $login = ftp_login($con, $ftp_user, $ftp_pass);
   if (@ftp_login($con, $ftp_user, $ftp_pass)) {
      echo "Connection established!";
   } else {
      echo "Failed in establishing a connection!";
   }
   ftp_close($con);
?>

Updated on: 30-Jul-2019

54 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements