Oh no! Where's the JavaScript?
Your Web browser does not have JavaScript enabled or does not support JavaScript. Please enable JavaScript on your Web browser to properly view this Web site, or upgrade to a Web browser that does support JavaScript.
Not a member yet? Click here to register.
Forgot Password?

FTP Login Code

Asked Modified Viewed 4,961 times
V
Vyper69
V
Unprecedented Times call for Unprecedented Measures
  • Senior Member, joined since
  • Contributed 551 posts on the community forums.
  • Started 146 threads in the forums
  • Started this discussions
asked
Senior Member

not sure if right forum, move if required.

Ok so I am trying to create a ftp login page.

here is the code.

<form action="ftp.php/" method="POST">
<p>Username<input name="username">
<p>Password<input name="password" type="password">
<p><input name="login" type="submit" value="login">

<?php
$conn = ftp_connect("ftp.elink2biz.com") or die("Could not connect");
ftp_login($conn,$login,$password);// print current directory
?>



</form>


The form shows up, but when i add the information in, it takes me back to my home page.
0 replies

8 posts

K
KasteR
K
KasteR 10
  • Senior Member, joined since
  • Contributed 290 posts on the community forums.
  • Started 1 thread in the forums
answered
Senior Member

You have $login as a variable. I'm assuming this is to be your username. Where is this coming from? You're using a variable that has no value, or has not been declared.

This is not the over all issue though. What are you trying to make? Some place to upload data from based on username? Or are you trying to access for read purposes?

And is the filename ftp.php?
0 replies
V
Vyper69
V
Unprecedented Times call for Unprecedented Measures
  • Senior Member, joined since
  • Contributed 551 posts on the community forums.
  • Started 146 threads in the forums
  • Started this discussions
answered
Senior Member

Basically what I am trying to do is create a ftp login page. When a user logs into the ftp, using their username and password, it will take them to their folder, or storage area. It should allow for download and upload, by the permissions i have set for them with my ftp management.

Some people don't want to download a client, I for one use fireftp with filezilla, but also have a client. But I also have google chrome and ie. IE I dont use except for checking compatibilty when I change themes around.

And actually the ftp address is 50.62.69.1
Edited by Vyper69 on 19-01-2013 02:35,
0 replies
L
Layzee
L
Layzee 10
Seen it - done it!
  • Member, joined since
  • Contributed 113 posts on the community forums.
  • Started 20 threads in the forums
answered
Member

Why not try a solution that already exists?
How about something like this? ===> http://www.net2ftp.com/
Highly customable and multiuser support.

Just install that client as Webservice on your Webspace and link to it...

Anyway, if you want to use your own script, you'll find a good tutorial here:
http://www.raditha.com/php/ftp/
Edited by Layzee on 19-01-2013 11:26,
0 replies
C
Centralsoft
C
Php-Fusion 7.02.07
php - 5.02 - 5.03 - 5.04
mysql - 5.5
Apache - 2.2

http://www.flayfm.tk/ http://www.flayfm.es/
  • Junior Member, joined since
  • Contributed 14 posts on the community forums.
  • Started 6 threads in the forums
answered
Junior Member

Quote

Layzee wrote:

Why not try a solution that already exists?
How about something like this? ===> http://www.net2ftp.com/
Highly customable and multiuser support.

Just install that client as Webservice on your Webspace and link to it...

Anyway, if you want to use your own script, you'll find a good tutorial here:
http://www.raditha.com/php/ftp/


It's a good good tutorial ftp, ftp basically now also use the hash of the login a pruba can do with your mail client with firefox roundcube can get the hash and come and go as they want and so does the ftp
0 replies
V
Vyper69
V
Unprecedented Times call for Unprecedented Measures
  • Senior Member, joined since
  • Contributed 551 posts on the community forums.
  • Started 146 threads in the forums
  • Started this discussions
answered
Senior Member

All I am really trying to do is have a simple form, nothing that complex. All the variables should already be there, all the user has to do is input their username and password, and it will connect them.
0 replies
L
Layzee
L
Layzee 10
Seen it - done it!
  • Member, joined since
  • Contributed 113 posts on the community forums.
  • Started 20 threads in the forums
answered
Member

Well, try this simple script for login:


<?php

$ftp_server = "ftp.example.com";
$ftp_user = "username";
$ftp_pass = "password";

// Connection
$cid = ftp_connect($ftp_server) or die("Couldn't connect to $ftp_server");

// Try to login
if (@ftp_login($cid, $ftp_user, $ftp_pass)) {
    echo "Logged in as $ftp_user@$ftp_server\n";
} else {
    echo "Login as $ftp_user failed\n";
}

// Close connection
ftp_close($cid);
?>


After you logged in successful, you have different possibilities and commands.
For example:

//Make directory
ftp_mkdir($cid, $remote_dir);
//delete directory
ftp_rmdir($cid, $remote_dir);
//file upload
ftp_put($cid, $local_file, $remode_file, $modus);
//file download
ftp_get($cid, $local_file, $remote_file, $modus);
//close FTP-connection
ftp_close($cid);



When you get some variables in the login form you posted first, you have to be sure that the variables has been set with right name. In your example, in loginform "username" is taken, in PHP-Script you are using "$login". So this variable has no content.

Hope that helps...
0 replies
V
Vyper69
V
Unprecedented Times call for Unprecedented Measures
  • Senior Member, joined since
  • Contributed 551 posts on the community forums.
  • Started 146 threads in the forums
  • Started this discussions
answered
Senior Member

Ok understanding that. But here is my problem with the code you provided. Basically it is having me to input username and password into the script. This is not possible.

It has to be generic, with a form, that a user can input their own username and password in a form, and then when they select login, it will direct them to the folder that is assigned to them.

In the format that you gave me, I would have to crete a seperate ftp login page per person.

So taking the 2 pieces of code is there a way to make this work.

<form action="ftp.php/" method="POST">
<p>Username<input name="username">
<p>Password<input name="password" type="password">
<p><input name="login" type="submit" value="login">

<?php

$ftp_server = "ftp.elink2biz.com";
$ftp_user = "username";
$ftp_pass = "password";

// Connection
$cid = ftp_connect($ftp_server) or die("Couldn't connect to $ftp_server");

// Try to login
if (@ftp_login($cid, $ftp_user, $ftp_pass)) {
    echo "Logged in as $ftp_user@$ftp_server\n";
} else {
    echo "Login as $ftp_user failed\n";
}

// Close connection
ftp_close($cid);
?>


my version doesn't work.

I mean if all else fails, they can download a client, or just use their browser with the login button I have. But what I want to do is incorporate this into a panel if possible.

The panel having the redirect to the ftp, using their login information.

Merged on Jan 21 2013 at 12:58:32:
Ok, sorry, I might have jumbled my words.

Here's what it need to accomplish.

1. Be in the form of a panel

2. Be a form, So user can input username and password.
This allows them to connect to their own folder
Edited by Vyper69 on 21-01-2013 19:58,
0 replies
— 4 months later —
S
sampei
S
sampei 10
link removed SPAM!
  • Newbie, joined since
  • Contributed 2 posts on the community forums.
  • Started 1 thread in the forums
answered
Newbie

Quote

Layzee wrote:

Why not try a solution that already exists?
How about something like this? ===> http://www.net2ftp.com/
Highly customable and multiuser support.

Just install that client as Webservice on your Webspace and link to it...

Anyway, if you want to use your own script, you'll find a good tutorial here:
http://www.raditha.com/php/ftp/


This thread caught my eye as I have recently been confronted by the same dilemma ...

I second Layzee suggestion ... don't try to reinvent the wheel ... net2ftp.com is a very good FTP client ... been out there for years and personally never heard of any vulnerability or so. You can even try it on their website connecting to your hosting - actually don't do this if it's important data as you are giving away your username and password - (however if that were the case I wouldn't recommend FTP in the first place as everything is sent as plain text)
Edited by sampei on 20-06-2013 12:16,
0 replies

Labels

None yet

Statistics

  • Views 0 views
  • Posts 8 posts
  • Votes 0 votes
  • Topic users 5 members

5 participants

C
C
Php-Fusion 7.02.07
php - 5.02 - 5.03 - 5.04
mysql - 5.5
Apache - 2.2

http://www.flayfm.tk/ http://www.flayfm.es/
  • Junior Member, joined since
  • Contributed 14 posts on the community forums.
  • Started 6 threads in the forums
L
L
Layzee 10
Seen it - done it!
  • Member, joined since
  • Contributed 113 posts on the community forums.
  • Started 20 threads in the forums
V
V
Unprecedented Times call for Unprecedented Measures
  • Senior Member, joined since
  • Contributed 551 posts on the community forums.
  • Started 146 threads in the forums
  • Started this discussions
K
K
KasteR 10
  • Senior Member, joined since
  • Contributed 290 posts on the community forums.
  • Started 1 thread in the forums
S
S
sampei 10
link removed SPAM!
  • Newbie, joined since
  • Contributed 2 posts on the community forums.
  • Started 1 thread in the forums

Notifications

Track thread

You are not receiving notifications from this thread.

Related Questions

Not yet