SnaD Posted June 22, 2006 Share Posted June 22, 2006 Hey guys. I really need a php script that would ask user for ftp login and pass. If they are correct, script would get user to specific ftp; otherwise, error. Anyone? Thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/12606-ftp-login/ Share on other sites More sharing options...
michaellunsford Posted June 22, 2006 Share Posted June 22, 2006 tried the sample code on php.net yet?[a href=\"http://us2.php.net/manual/en/function.ftp-login.php\" target=\"_blank\"]http://us2.php.net/manual/en/function.ftp-login.php[/a] Quote Link to comment https://forums.phpfreaks.com/topic/12606-ftp-login/#findComment-48345 Share on other sites More sharing options...
SnaD Posted June 22, 2006 Author Share Posted June 22, 2006 [!--quoteo(post=386709:date=Jun 21 2006, 09:45 PM:name=michaellunsford)--][div class=\'quotetop\']QUOTE(michaellunsford @ Jun 21 2006, 09:45 PM) [snapback]386709[/snapback][/div][div class=\'quotemain\'][!--quotec--]tried the sample code on php.net yet?[a href=\"http://us2.php.net/manual/en/function.ftp-login.php\" target=\"_blank\"]http://us2.php.net/manual/en/function.ftp-login.php[/a][/quote]Thanks, im gonna try it now. Quote Link to comment https://forums.phpfreaks.com/topic/12606-ftp-login/#findComment-48450 Share on other sites More sharing options...
SnaD Posted June 23, 2006 Author Share Posted June 23, 2006 It did work but not exactly how I wanted it to. It just outputs "Connected as user@server.com," whereas I want it to redirect user to ftp server. Anyone? Appreciate it. Quote Link to comment https://forums.phpfreaks.com/topic/12606-ftp-login/#findComment-48663 Share on other sites More sharing options...
michaellunsford Posted June 23, 2006 Share Posted June 23, 2006 To simply redirect the browser to a ftp site that requires a login and password, you just have to know the language. Once you've got that, you can create a hyperlink, do a header redirect, or any number of things. Here's the language:[a href=\"ftp://user:password@ftp.example.com\" target=\"_blank\"]ftp://user:password@ftp.example.com[/a]I believe most browser supports this. Challenge, of course, is you're sending the username and password in plain text across the internet. But, come to think of it, standard FTP does the same thing. Quote Link to comment https://forums.phpfreaks.com/topic/12606-ftp-login/#findComment-48667 Share on other sites More sharing options...
SnaD Posted June 23, 2006 Author Share Posted June 23, 2006 Here is a part of my code:<?php if(isset($_POST['submit'])) { header("Location:ftp://".$_GET['log'].":".$_GET['pass']."@server.com"); exit; } else {?> <table border="0" cellspacing="0" cellpadding="0"> <tr> <td class="titleblue"> Username </td> <td> <input name="log" type="text" style="color:013B84;font-weight:bold;background-color:transparent;border-color:013B84;border-width:1;border-style:solid"> </td> </tr> <tr> <td class="titleblue"> Password </td> <td> <input name="pass" type="password" style="cime-mode:active;color:013B84;font-weight:bold;background-color:transparent;border-color:013B84;border-width:1;border-style:solid"> </td> </tr> <tr> <td width="10"> </td> <td align="center"> <input type="submit" name="submit" value="Login" style="cursor:hand;font-weight:bold;color:000099;background-color:white;border-color:013B84;border-width:1;border-style:solid"> </td> <td width="30"> </td> </tr> </table><?php}?>I get this warning:Warning: Cannot modify header information - headers already sent by (output started at C:\site\NEW\client_access.php:5) in C:\site\NEW\client_access.php on line 85Any ideas? What am I doing wrong? Quote Link to comment https://forums.phpfreaks.com/topic/12606-ftp-login/#findComment-48677 Share on other sites More sharing options...
michaellunsford Posted June 23, 2006 Share Posted June 23, 2006 you either need to buffer output, or not output any information before the header. This is in the FAQ if you have more questions.[a href=\"http://www.phpfreaks.com/forums/index.php?showtopic=95562\" target=\"_blank\"]http://www.phpfreaks.com/forums/index.php?showtopic=95562[/a]For testing purposes you could include a javascript code to get you going. It should simulate a header redirect until you get your PHP header problem addressed. You will eventually want to use the PHP method, though, because not all visitors will have javascript turned on.[code]<script language="javascript">window.location = "http://www.example.com"; </script>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/12606-ftp-login/#findComment-48680 Share on other sites More sharing options...
SnaD Posted June 29, 2006 Author Share Posted June 29, 2006 Hey guys, I have one more problem. Here is my code to ftp.php. Smth strange is happening.When I submit my form, IE says that my ftp.php not found (404), whereas Firefox connects to ftp, but gives me "426 Connection Closed" error. Anyone knows how to fix this? Thanks.[code]<?php $ftp_server = "mysite.com";$ftp_user = $_REQUEST['log'];$ftp_pass = $_REQUEST['pass'];// set up a connection or die$conn_id = ftp_connect($ftp_server) or die("Couldn't connect to $ftp_server"); // try to loginif (@ftp_login($conn_id, $ftp_user, $ftp_pass)) { header("Location: ftp://$ftp_user:$ftp_pass@$ftp_server");} else { include 'error_ftp.htm';}// close the connectionftp_close($conn_id);?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/12606-ftp-login/#findComment-50988 Share on other sites More sharing options...
michaellunsford Posted June 29, 2006 Share Posted June 29, 2006 If you have unix, try curling the pagecurl -I -dlog=loginname -dpass=password [a href=\"http://www.example.com/ftp.php\" target=\"_blank\"]http://www.example.com/ftp.php[/a]the uppercase "I" will return the header only, so you can see where it's trying to send you. Copy the address and plug it in your browser. Quote Link to comment https://forums.phpfreaks.com/topic/12606-ftp-login/#findComment-50997 Share on other sites More sharing options...
SnaD Posted June 29, 2006 Author Share Posted June 29, 2006 [!--quoteo(post=389434:date=Jun 29 2006, 03:36 PM:name=michaellunsford)--][div class=\'quotetop\']QUOTE(michaellunsford @ Jun 29 2006, 03:36 PM) [snapback]389434[/snapback][/div][div class=\'quotemain\'][!--quotec--]If you have unix, try curling the pagecurl -I -dlog=loginname -dpass=password [a href=\"http://www.example.com/ftp.php\" target=\"_blank\"]http://www.example.com/ftp.php[/a]the uppercase "I" will return the header only, so you can see where it's trying to send you. Copy the address and plug it in your browser.[/quote]No, I don't have unix :( Quote Link to comment https://forums.phpfreaks.com/topic/12606-ftp-login/#findComment-51016 Share on other sites More sharing options...
michaellunsford Posted June 29, 2006 Share Posted June 29, 2006 go to [a href=\"http://web-sniffer.net/\" target=\"_blank\"]http://web-sniffer.net/[/a]put in your url like this:[a href=\"http://www.example.com/ftp.php?log=username&pass=password\" target=\"_blank\"]http://www.example.com/ftp.php?log=username&pass=password[/a]select the "POST" radio headersubmit. Quote Link to comment https://forums.phpfreaks.com/topic/12606-ftp-login/#findComment-51020 Share on other sites More sharing options...
SnaD Posted June 29, 2006 Author Share Posted June 29, 2006 [!--quoteo(post=389457:date=Jun 29 2006, 04:11 PM:name=michaellunsford)--][div class=\'quotetop\']QUOTE(michaellunsford @ Jun 29 2006, 04:11 PM) [snapback]389457[/snapback][/div][div class=\'quotemain\'][!--quotec--]go to [a href=\"http://web-sniffer.net/\" target=\"_blank\"]http://web-sniffer.net/[/a]put in your url like this:[a href=\"http://www.example.com/ftp.php?log=username&pass=password\" target=\"_blank\"]http://www.example.com/ftp.php?log=username&pass=password[/a]select the "POST" radio headersubmit.[/quote]Nevermind, i figured it out. It was because of my stupid server. Anyways, I appreciate ur help.One more thing [img src=\"style_emoticons/[#EMO_DIR#]/smile.gif\" style=\"vertical-align:middle\" emoid=\":smile:\" border=\"0\" alt=\"smile.gif\" /] die("Couldn't connect to $ftp_server"); Is there a way to insert html page in die() instead of just saying "Couldn't connect to $ftp_server" Quote Link to comment https://forums.phpfreaks.com/topic/12606-ftp-login/#findComment-51028 Share on other sites More sharing options...
michaellunsford Posted June 29, 2006 Share Posted June 29, 2006 I'm not a die() expert, however I believe it echo's whatever you put in the quotes, and stops processing the document. Quote Link to comment https://forums.phpfreaks.com/topic/12606-ftp-login/#findComment-51031 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.