Can I use Forms to get username and passwords for FTP?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
murph2481
Forum Newbie
Posts: 20
Joined: Mon Jun 27, 2005 1:48 pm

Can I use Forms to get username and passwords for FTP?

Post by murph2481 »

Is there a way I can write a form that captures username and password and sends it to an ftp server?

I know I could do a submit and do something like ftp://$username:$password@ftp.domain.com

But wondering if there are any other ways...

Thanks in advance,
Dan
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

what are you wanting to do (end goal) with this?

there are php internal ftp functions that may help, if you want to "hide" it...
murph2481
Forum Newbie
Posts: 20
Joined: Mon Jun 27, 2005 1:48 pm

FTP Form username and password

Post by murph2481 »

This is going back to the same problem as the....if this browser do this....if that browser do that. I just thought maybe there was a way I could submit username and password to a FTP and get in other than in the URL or maybe there are some specail charcters i can use in the URL?

My employeer wants a link to his FTP server on his site. Well I cannot just put a link because it tries to login annonymously. If i supply a username it prompts me for a password and then i can enter on and get in. Problem is my username has an @ (user@domain.com) in it which throws off IE and Firefox. I can use a + (user+domain.com) instead but that only works on IE, Firefox doesn't like it. So instead of codeing if else statements based on the hundreds of browsers out there was wondering if i could send the username and password to the FTP site through form submission.

Basically i am looking for a way to always force a prompt for login information for the FTP server coming through the website. I know this is tough because of the different browsers but that is why i am on the forums asking about it :lol:

Thanks,
Dan
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

try to rawurlencode() the username and password

as an example:

Code: Select all

$username = 'smee@foo.com';
$password = 'floob';
$domain = 'ftp.foo.com';

echo rawurlencode($username).':'.rawurlencode($password).'@'.$domain;
outputs

Code: Select all

smee%40foo.com:floob@ftp.foo.com
murph2481
Forum Newbie
Posts: 20
Joined: Mon Jun 27, 2005 1:48 pm

Thanks

Post by murph2481 »

I will have to try that. I just took over their site this week and they are all straight HTML so I have to move their pages over to PHP. After that conversion takes place I will try it.

Thank You!
Dan
Post Reply