using the $ftp_server

Reply

Join Date: Nov 2006
Posts: 39
Reputation: krauz2 is an unknown quantity at this point 
Solved Threads: 0
krauz2 krauz2 is offline Offline
Light Poster

using the $ftp_server

 
0
  #1
Oct 12th, 2008
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;
}
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 849
Reputation: R0bb0b is on a distinguished road 
Solved Threads: 67
R0bb0b's Avatar
R0bb0b R0bb0b is offline Offline
Practically a Posting Shark

Re: using the $ftp_server

 
1
  #2
Oct 12th, 2008
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";
“Be who you are and say what you feel because those who mind don't matter and those who matter don't mind.” - Dr. Seuss

-- The documentation is inevitable, you may get away with it for a little while but eventually you too will have to do the deed.
Reply With Quote Quick reply to this message  
Join Date: Nov 2006
Posts: 39
Reputation: krauz2 is an unknown quantity at this point 
Solved Threads: 0
krauz2 krauz2 is offline Offline
Light Poster

Re: using the $ftp_server

 
0
  #3
Oct 12th, 2008
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.

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

  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
Reply With Quote Quick reply to this message  
Join Date: Nov 2006
Posts: 39
Reputation: krauz2 is an unknown quantity at this point 
Solved Threads: 0
krauz2 krauz2 is offline Offline
Light Poster

Re: using the $ftp_server

 
0
  #4
Oct 12th, 2008
I just want it to pop up depending on which option I pick so I can have the user log-in via ftp
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 849
Reputation: R0bb0b is on a distinguished road 
Solved Threads: 67
R0bb0b's Avatar
R0bb0b R0bb0b is offline Offline
Practically a Posting Shark

Re: using the $ftp_server

 
0
  #5
Oct 12th, 2008
This function always works for me:
  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.
“Be who you are and say what you feel because those who mind don't matter and those who matter don't mind.” - Dr. Seuss

-- The documentation is inevitable, you may get away with it for a little while but eventually you too will have to do the deed.
Reply With Quote Quick reply to this message  
Join Date: Nov 2006
Posts: 39
Reputation: krauz2 is an unknown quantity at this point 
Solved Threads: 0
krauz2 krauz2 is offline Offline
Light Poster

Re: using the $ftp_server

 
0
  #6
Oct 12th, 2008
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
Reply With Quote Quick reply to this message  
Join Date: Nov 2006
Posts: 39
Reputation: krauz2 is an unknown quantity at this point 
Solved Threads: 0
krauz2 krauz2 is offline Offline
Light Poster

Re: using the $ftp_server

 
0
  #7
Oct 12th, 2008
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.
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 849
Reputation: R0bb0b is on a distinguished road 
Solved Threads: 67
R0bb0b's Avatar
R0bb0b R0bb0b is offline Offline
Practically a Posting Shark

Re: using the $ftp_server

 
0
  #8
Oct 12th, 2008
Originally Posted by krauz2 View Post
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
“Be who you are and say what you feel because those who mind don't matter and those who matter don't mind.” - Dr. Seuss

-- The documentation is inevitable, you may get away with it for a little while but eventually you too will have to do the deed.
Reply With Quote Quick reply to this message  
Join Date: Nov 2006
Posts: 39
Reputation: krauz2 is an unknown quantity at this point 
Solved Threads: 0
krauz2 krauz2 is offline Offline
Light Poster

Re: using the $ftp_server

 
0
  #9
Oct 12th, 2008
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.
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 849
Reputation: R0bb0b is on a distinguished road 
Solved Threads: 67
R0bb0b's Avatar
R0bb0b R0bb0b is offline Offline
Practically a Posting Shark

Re: using the $ftp_server

 
0
  #10
Oct 12th, 2008
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
“Be who you are and say what you feel because those who mind don't matter and those who matter don't mind.” - Dr. Seuss

-- The documentation is inevitable, you may get away with it for a little while but eventually you too will have to do the deed.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the PHP Forum
Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC