943,602 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 1795
  • PHP RSS
You are currently viewing page 1 of this multi-page discussion thread
Oct 12th, 2008
0

using the $ftp_server

Expand Post »
I am trying to use a switch statement and want the action to be log into a ftp server.
I am not able to get it to work...can anyone help?

here is what I have now....Thanks everyone in advance.

$ftp_server = "ftp://MyFtpSite.com";

$ftp_server = $employeeftp;

switch($attn1) { // this is from the other page
case 'employees': // case employees, it should take you to my ftp site
$conn_id = ftp_connect($employeeftp);

break;
}
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
krauz2 is offline Offline
39 posts
since Nov 2006
Oct 12th, 2008
1

Re: using the $ftp_server

You do not include the protocol with the servername when you use ftp_connect so change this line:
$ftp_server = "ftp://MyFtpSite.com";
to this:
$ftp_server = "MyFtpSite.com";
Reputation Points: 358
Solved Threads: 89
Posting Shark
R0bb0b is offline Offline
986 posts
since Jun 2008
Oct 12th, 2008
0

Re: using the $ftp_server

Thanks for the help. I have been at this for days now. So far I have got the switch command to work to send out a email if the "case" is correct. I now want to have the CASE go to a ftp site or a URL.

Here is where I am at. Please any help is good help.

-----------------------------------------

php Syntax (Toggle Plain Text)
  1. $ftp_server = "MyFtpSite"; // after your input..thanks
  2. $ftp_user = "myName@com";
  3. $FTP_pass = "mypassword";
  4.  
  5. $conn_id = ftp_connect($ftp_server) or die("could not do it erich");
  6.  
  7.  
  8.  
  9.  
  10. switch($attn1) {
  11. case 'employees':
  12. if (@ftp_login($conn_id, $ftp_user, $ftp_pass))
  13. {
  14. echo "you did it erich";
  15. }
  16. else {
  17. echo "nice try erich";
  18. }
  19.  
  20. break;
  21.  
  22.  
  23. }
Last edited by cscgal; Oct 12th, 2008 at 11:12 am. Reason: Added code tags
Reputation Points: 10
Solved Threads: 0
Light Poster
krauz2 is offline Offline
39 posts
since Nov 2006
Oct 12th, 2008
0

Re: using the $ftp_server

I just want it to pop up depending on which option I pick so I can have the user log-in via ftp
Reputation Points: 10
Solved Threads: 0
Light Poster
krauz2 is offline Offline
39 posts
since Nov 2006
Oct 12th, 2008
0

Re: using the $ftp_server

This function always works for me:
php Syntax (Toggle Plain Text)
  1. <?php
  2. /**
  3. * connect to ftp
  4. * @access public
  5. *
  6. * return object or false
  7. */
  8. function connect_ftp()
  9. {
  10. //FTP connection
  11. $ftp_server="servername";
  12. $ftp_user_name="username";
  13. $ftp_user_pass="password";
  14. $conn=ftp_connect($ftp_server);
  15. //if ($conn) echo "Server connected: $ftp_server<br>";
  16. $login=ftp_login($conn, $ftp_user_name, $ftp_user_pass);
  17. //if ($login) echo "User '$ftp_user_name' logged in.<br>";
  18.  
  19. return $login?$conn:false;
  20. }
  21.  
  22.  
  23.  
  24.  
  25. switch($attn1)
  26. {
  27. case 'employees':
  28. if($conn_id = connect_ftp())
  29. {
  30. echo "you did it erich";
  31. }
  32. else
  33. {
  34. echo "nice try erich";
  35. }
  36. break;
  37. }
  38. ?>
Last edited by R0bb0b; Oct 12th, 2008 at 9:36 pm.
Reputation Points: 358
Solved Threads: 89
Posting Shark
R0bb0b is offline Offline
986 posts
since Jun 2008
Oct 12th, 2008
0

Re: using the $ftp_server

Sweet, I got it to connect but now thats all it says is connected....Is there a way of viewing my files and folders from my ftp site so I can add to them? LOL Thanks so much for heping me. I am starting to get this.
Erich
Reputation Points: 10
Solved Threads: 0
Light Poster
krauz2 is offline Offline
39 posts
since Nov 2006
Oct 12th, 2008
0

Re: using the $ftp_server

You know like in my computer you are free to drag and drop files in folders. I would like to have that same interface...if I am even heading down that road.
Reputation Points: 10
Solved Threads: 0
Light Poster
krauz2 is offline Offline
39 posts
since Nov 2006
Oct 12th, 2008
0

Re: using the $ftp_server

Click to Expand / Collapse  Quote originally posted by krauz2 ...
Sweet, I got it to connect but now thats all it says is connected....Is there a way of viewing my files and folders from my ftp site so I can add to them? LOL Thanks so much for heping me. I am starting to get this.
Erich
Absolutely, its just like standard file manipulation functions except they have "ftp_" in front of them. Here is a list of all of the functions, each one having examples of how to use them:
http://us.php.net/manual/en/ref.ftp.php
Reputation Points: 358
Solved Threads: 89
Posting Shark
R0bb0b is offline Offline
986 posts
since Jun 2008
Oct 12th, 2008
0

Re: using the $ftp_server

How about making it so the user has to input the user name and password?

I tried to have it = ""; but it was not working for me.
Reputation Points: 10
Solved Threads: 0
Light Poster
krauz2 is offline Offline
39 posts
since Nov 2006
Oct 12th, 2008
0

Re: using the $ftp_server

I don't know how much you know about functions but you will want to pass the username and password to the function as arguments, here is the manual on function arguments:
http://us.php.net/manual/en/functions.arguments.php
Reputation Points: 358
Solved Threads: 89
Posting Shark
R0bb0b is offline Offline
986 posts
since Jun 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC