?
Solved

Login script

Posted on 2006-07-14
5
Medium Priority
?
213 Views
Last Modified: 2008-03-17
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?

<?php
$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
ftp_close($conn_id);
?>

0
Comment
Question by:Yury Merezhkov
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 33

Accepted Solution

by:
snoyes_jw earned 1000 total points
ID: 17111760
use urlencode on $ftp_user and $ftp_pass
0
 
LVL 14

Expert Comment

by:ThG
ID: 17111780
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.
0
 
LVL 14

Expert Comment

by:ThG
ID: 17111793
well... snoyes_jw's idea ain't bad at all! good point.
0
 
LVL 7

Author Comment

by:Yury Merezhkov
ID: 17111865
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 :)
0
 
LVL 7

Author Comment

by:Yury Merezhkov
ID: 17111876
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.
0

Featured Post

Are You Using the Best Web Development Editor?

The worlds of web hosting and web development are constantly evolving. Every year we see design trends change, coding standards adapt and new frameworks/CMS created. With such a quick pace of change it’s easy to get lost trying to keep up.

See if your editor made the list.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question