Kruse Posted July 29, 2008 Posted July 29, 2008 (edited) Hey everyone,I'm writing an FTP script in PHP and I know the upload is working (tested it with out the HTML form), but as soon as I put a form in it to post some data to another page, it no longer works. the data i'm trying to post are in hidden fields in an html form:<input type="hidden" name="action2" value="up"><input type="hidden" name="hostname" value=<?php $hostname ?>><input type="hidden" name="user" value=<?php $user ?>><input type="hidden" name="password" value=<?php $password ?>>where all the values were posted from another page and put into these vars (except for action2, which is also the only one which is read properly). When I try to pick them back up on the next page, they all return empty strings. Could anyone give me a reason why? Edited July 29, 2008 by Kruse
4e4en Posted July 29, 2008 Posted July 29, 2008 It's not possible.Because, every time script finishes, ftp connection are closed. And Even if it wouldn't you can't transfare that connection, to another script.
Kruse Posted July 29, 2008 Author Posted July 29, 2008 It's not possible.Because, every time script finishes, ftp connection are closed. And Even if it wouldn't you can't transfare that connection, to another script.I changed that so the connection is in the script it should be in and made the edits above (seemingly while you were posting your respose!) those fields i'm posting are entered by the user.
n0p Posted July 30, 2008 Posted July 30, 2008 Add "quotes" around the values and maybe try using $_POST['hostname'] etc instead of just $hostname.
Kruse Posted July 30, 2008 Author Posted July 30, 2008 (edited) alright, so i made the suggested changes, so I now have: <?php $action = $_POST['action']; $hostname = $_POST['hostname']; $user = $_POST['user']; $password = $_POST['password']; switch($action) { case 'upload':?><form action="transferScript.php" method="post"><table align="center">...</table><input type="hidden" name="action2" value="up"><input type="hidden" name="hostname" value="<?php $_POST['hostname'] ?>"><input type="hidden" name="user" value="<?php $_POST['user'] ?>"><input type="hidden" name="password" value="<?php $_POST['password'] ?>"></form>then in the next file: $action = $_POST['action2']; $hostname = $_POST['hostname']; echo "hostname $hostname"; $user = $_POST['user']; $password = $_POST['password']; echo "<br>user: $user <br>pass: $password"; $conn_id = ftp_connect($hostname); $login_result = ftp_login($conn_id, $user, $password);In the echos, none of the variables print anything out, and it gets a:Fatal error: Maximum execution time of 30 seconds exceededon the $conn_id = ftp_login($conn_id, $user, $password); line. anyone have any ideas?Thanks again.p.s. register globals is enabled Edited July 30, 2008 by Kruse
glaufan Posted July 31, 2008 Posted July 31, 2008 alright, so i made the suggested changes, so I now have: <?php $action = $_POST['action']; $hostname = $_POST['hostname']; $user = $_POST['user']; $password = $_POST['password']; switch($action) { case 'upload':?><form action="transferScript.php" method="post"><table align="center">...</table><input type="hidden" name="action2" value="up"><input type="hidden" name="hostname" value="<?php $_POST['hostname'] ?>"><input type="hidden" name="user" value="<?php $_POST['user'] ?>"><input type="hidden" name="password" value="<?php $_POST['password'] ?>"></form>then in the next file: $action = $_POST['action2']; $hostname = $_POST['hostname']; echo "hostname $hostname"; $user = $_POST['user']; $password = $_POST['password']; echo "<br>user: $user <br>pass: $password"; $conn_id = ftp_connect($hostname); $login_result = ftp_login($conn_id, $user, $password);In the echos, none of the variables print anything out, and it gets a:Fatal error: Maximum execution time of 30 seconds exceededon the $conn_id = ftp_login($conn_id, $user, $password); line. anyone have any ideas?Thanks again.p.s. register globals is enabledyou may not see anything echo'd because the IO is buffered, either flush the buffer, change the buffering mode or just add \n to the end of the strings you are echo'ing
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now