Login script

Hi guys,

i have this ftp login script on my website. It works just fine. One little problem is that when I enter @ in either name or password it doesn't work. Any ideas?

$ftp_server = "server.com";
$ftp_user = $_REQUEST['log'];
$ftp_pass = $_REQUEST['pass'];

// set up a connection or die
$conn_id = ftp_connect($ftp_server) or die("Error!");

// try to login
if (@ftp_login($conn_id, $ftp_user, $ftp_pass)) {
   header("Location: ftp://".$ftp_user.":".$ftp_pass."@".$ftp_server);
} else {
   include "error_ftp.htm";

// close the connection

Yury MerezhkovDevelopment Team LeadAsked:
Who is Participating?
snoyes_jwConnect With a Mentor Commented:
use urlencode on $ftp_user and $ftp_pass
it cannot work obviously, because the browser mismatches the "@" in the login for the host part of the URI.

some providers that require the "@" in the login name sometimes accepts a "+" also.. using str_replace("@", "+", $ftp_user); might help.
well... snoyes_jw's idea ain't bad at all! good point.
Yury MerezhkovDevelopment Team LeadAuthor Commented:
I'd say perfect point. It worked. Funny thing is that in Firefox after redirect the url address is ftp://server.com, whereas in IE it becomes ftp://X@server.com. Where X = whatever was after @ in password :)
Yury MerezhkovDevelopment Team LeadAuthor Commented:
So basically, if user's password starts with @ the rest of it will be shown in the address bar :) Anyways, who cares. Thank you guys.
All Courses

From novice to tech pro — start learning today.