Solved

Login script

Posted on 2006-07-14
5
207 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:RealSnaD
  • 2
  • 2
5 Comments
 
LVL 33

Accepted Solution

by:
snoyes_jw earned 250 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:RealSnaD
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:RealSnaD
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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
AJAX pass along a variable 3 46
Email called spam 5 36
Number of reviews not counting correctly 2 22
PHP website on Linux - server DNS address could not be found. 18 45
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 …
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

840 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