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

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

commented: Very helpful, thanks again +2

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;


}

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

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<br>";
        $login=ftp_login($conn, $ftp_user_name, $ftp_user_pass);
        //if ($login) echo "User '$ftp_user_name' logged in.<br>";
       
        return $login?$conn:false;
}




switch($attn1)
{
	case 'employees':
		if($conn_id = connect_ftp())
		{
			echo "you did it erich";
		}
		else
		{
			echo "nice try erich";
		}
		break;
}
?>

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

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.

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

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.

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.

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.