1 Replies - 531 Views - Last Post: 17 September 2012 - 03:02 AM Rate Topic: -----

#1 rajivlove66@gmail.com  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 16-September 12

FTP Login Page

Posted 16 September 2012 - 09:59 PM

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<?php
$error='';
if(isset($_REQUEST['btnsubmit']))
{
if(isset($_REQUEST['name'])){if($_REQUEST['name']<>""){$name= $_REQUEST['name'];}
	else { $error.="Please Enter Your User Id.....<br>";}} 
	if(isset($_REQUEST['pass'])){if($_REQUEST['pass']<>""){$pass= $_REQUEST['pass'];}
	else { $error.="Please Enter Your Password.....<br>";}} 
if($error=='')
{
// set up basic connection
$ftp_server = "IP Address";
$conn_id = ftp_connect($ftp_server);

// login with username and password
$ftp_user_name = "$name";
$ftp_user_pass = "$pass";
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
ftp_pasv($conn_id, true);
// check connection
if ((!$conn_id) || (!$login_result)) {
        echo "FTP connection has failed!";
        echo "Attempted to connect to $ftp_server for user $ftp_user_name";
        exit;
    } else {
        echo "Connected to $ftp_server, for user $ftp_user_name";
    }
	}
else
{ echo $error;}
$buff = ftp_nlist($conn_id,".");
print_r($buff);
ftp_close($conn_id); 
}
?>
<form name="Login" method="post">
 <table width="50%" border="0" align="center">
    <tr> 
	  <td colspan="3" bgcolor="#FF9900"> 
        <div align="center"><strong><font color="#FFFFFF" size="6">FTP  Login</font></strong></div></td>
    </tr>
    <tr> 
	<td width="24%" rowspan="3"><img src="image/Login.gif" width="132" height="100"></td>   
      <td width="33%" height="62"><p>&nbsp;</p>
        <p align="center"><strong><font color="#FF9900">U</font>ser ID</strong></p></td>
      <td width="43%"><p>&nbsp; </p>
        <p> 
          <input name="name" type="text" id="name">
        </p></td>
    </tr>
    <tr> 
      <td height="71"><div align="center"><strong><font color="#FF9900">P</font>assword</strong></div></td>
      <td><input name="pass" type="password" id="pass"></td>
    </tr>
    <tr> 
      <td height="26"> <div align="right">
          <input type="submit" name="btnsubmit" value="Submit" >
        </div></td>
      <td height="26"><input type="reset" name="reset" value="Reset"></td>
    </tr>
</table>
</form>
</body>
</html>




Please help
I want to create a login page through php for ftp server linux os.
Through the above code I got access to ftp server but i not able to access the folder because the output coming in array format neither in folder format.

MOD EDIT: Added code tags and split into new topic

This post has been edited by JackOfAllTrades: 17 September 2012 - 02:59 AM


Is This A Good Question/Topic? 0
  • +

Replies To: FTP Login Page

#2 JackOfAllTrades  Icon User is online

  • Saucy!
  • member icon

Reputation: 5951
  • View blog
  • Posts: 23,215
  • Joined: 23-August 08

Re: FTP Login Page

Posted 17 September 2012 - 03:02 AM

When you post code, USE CODE TAGS!!! Like this:

:code:

Please do not hijack old, barely-related topics; create a new one. I've split your post off into a new topic.

Yes, ftp_nlist returns an array. It's your responsibility to process that array for display in whatever format you want.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1