Posted July 29, 200817 yr 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, 200817 yr by Kruse
July 29, 200817 yr 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.
July 29, 200817 yr Author 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.
July 30, 200817 yr Add "quotes" around the values and maybe try using $_POST['hostname'] etc instead of just $hostname.
July 30, 200817 yr Author 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, 200817 yr by Kruse
July 31, 200817 yr 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
Create an account or sign in to comment