954,561 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

using the $ftp_server

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;
}

krauz2
Light Poster
40 posts since Nov 2006
Reputation Points: 10
Solved Threads: 0
 

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";

R0bb0b
Posting Shark
998 posts since Jun 2008
Reputation Points: 358
Solved Threads: 89
 

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.

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

$ftp_server = "MyFtpSite";  // after your input..thanks
$ftp_user = "myName@com";
$FTP_pass = "mypassword";
 
$conn_id = ftp_connect($ftp_server) or die("could not do it erich");




switch($attn1) {
case 'employees':
if (@ftp_login($conn_id, $ftp_user, $ftp_pass))
 {
echo "you did it erich";
}
else {
echo "nice try erich";
} 

break;


}
krauz2
Light Poster
40 posts since Nov 2006
Reputation Points: 10
Solved Threads: 0
 

I just want it to pop up depending on which option I pick so I can have the user log-in via ftp

krauz2
Light Poster
40 posts since Nov 2006
Reputation Points: 10
Solved Threads: 0
 

This function always works for me:

<?php
/**
* connect to ftp
* @access public
* 
* return object or false
*/
function connect_ftp()
{
        //FTP connection
        $ftp_server="servername";
        $ftp_user_name="username";
        $ftp_user_pass="password";
        $conn=ftp_connect($ftp_server);
        //if ($conn) echo "Server connected: $ftp_server";
        $login=ftp_login($conn, $ftp_user_name, $ftp_user_pass);
        //if ($login) echo "User '$ftp_user_name' logged in.";
       
        return $login?$conn:false;
}




switch($attn1)
{
	case 'employees':
		if($conn_id = connect_ftp())
		{
			echo "you did it erich";
		}
		else
		{
			echo "nice try erich";
		}
		break;
}
?>
R0bb0b
Posting Shark
998 posts since Jun 2008
Reputation Points: 358
Solved Threads: 89
 

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

krauz2
Light Poster
40 posts since Nov 2006
Reputation Points: 10
Solved Threads: 0
 

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.

krauz2
Light Poster
40 posts since Nov 2006
Reputation Points: 10
Solved Threads: 0
 
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

R0bb0b
Posting Shark
998 posts since Jun 2008
Reputation Points: 358
Solved Threads: 89
 

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.

krauz2
Light Poster
40 posts since Nov 2006
Reputation Points: 10
Solved Threads: 0
 

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

R0bb0b
Posting Shark
998 posts since Jun 2008
Reputation Points: 358
Solved Threads: 89
 

sweet, one last questions then I think I will be trying to plug all this together. After It has logged in, how can I get internet explorer to give me that visual look like my computer. Right now, it is only telling me it logged on once I click the php script. Thanks again for your help.

krauz2
Light Poster
40 posts since Nov 2006
Reputation Points: 10
Solved Threads: 0
 

You will have to either design it yourself or look for one online: http://www.google.com/search?hl=en&q=php+ftp+online+script&btnG=Search

R0bb0b
Posting Shark
998 posts since Jun 2008
Reputation Points: 358
Solved Threads: 89
 

Thank you, now for the fun part, trial and error...lol

krauz2
Light Poster
40 posts since Nov 2006
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You