Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Jan 2010
    Posts
    14
    Thanks
    1
    Thanked 0 Times in 0 Posts

    calling an FTP script..

    Hey everyone,

    Im quite new to PHP and learning PHP as i go. To jump in the deep end, im trying to create a PHP FTP page and im stuck at the login screen. I can validate the user but i want is to be able to redirect the user on successful login within the php code. Is this even possible? Ive googled and there are plenty of long winded functions but there must be a quick method.. surely! I cant think of any other way to achieve the redirect, what i really need is to be able to call another php script halfway through the script on my main page..

    Any tips are more than welcome!!

  • #2
    New Coder
    Join Date
    May 2007
    Location
    Manchester, UK
    Posts
    72
    Thanks
    0
    Thanked 2 Times in 2 Posts
    As per http://php.net/header:

    PHP Code:
    header("Location: http://www.example.com/"); 
    Note that you can't send headers after outputting; so don't echo any HTML etc. prior to executing that.
    Every PHP programmer of any skill level should set error_reporting(E_ALL); at the top of their scripts or in their php.ini

  • #3
    New Coder
    Join Date
    Jan 2010
    Posts
    14
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Thats one of the things that i had come across initially, but the way im thinking that i would like to go about it, i will need to echo output out first, if that makes sense. I may be going about this the completly wrong way but, i have a page for input that passes to the code below the credentials. What id like is to display a message if the credentials are incorrect otherwise call another script to carry out some other action. This is mainly so that i can have a "logged in page" which obviously the first page wont contain. Hope that makes sense!

    PHP Code:
    $conn = @ftp_connect($ftpServer)
    or die(
    "<BR><center><font style='color:#9dacbe'>Couldn't connect to FTP server</font></center>");
    $login = @ftp_login($conn$ftpUser$ftpPass)
    or die(
    "<BR><center><font style='color:#9dacbe'>Login credentials were rejected or incorrect.</font></center>");

    $workingDir ftp_pwd($conn); 
    // Redirect to go here..
    //on successful login redirect to ftp.php so i can list files on FTP server 
    Am i going about this the wrong way, or is there something ive missed..??


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •