savio_mf Posted April 9, 2007 Share Posted April 9, 2007 HI everybody, I am making a file upload system in php which is broken down in two stages. Stage one uploads the file to the server using php, if this is successful, it goes to stage 2 which basically asks the user to input the title for this file to store in the database and also stores the file name in the same database. The problem where I am stuck is when I try to send the file name from stage 1 to stage 2 in the URL (.php?filename=$filename). I just cant seem to retrieve it form this URL in stage 2. (retrieve the file name which is in the URL to pot it in the database along with the tile) I have posted the code below. Please can someone help, Will be greatly appreciated. Stage one: partial source from After the file has been uploaded $name= $_FILES['file']['name']; print "Your file has been uploaded successfully, please proceed to the next step"; echo "<a href='newoffer1.php?filename=$name'>Cick here</a>"; Stage two: newoffer1.php <?php $filename = $_GET['filename']; if (isset($_POST['title'])): // A new Offer has been entered // using the form below. $dbcnx = @mysql_connect('localhost', 'root', 'xxxxx'); if (!$dbcnx) { exit('<p>Unable to connect to the ' . 'database server at this time.</p>'); } if (!@mysql_select_db('abcd')) { exit('<p>Unable to locate the ' . 'database at this time.</p>'); } $title = $_POST['title']; $sql = "INSERT INTO offer SET title='$title', filename='$filename'"; if (@mysql_query($sql)) { echo '<p>Details updated</p>'; } else { echo '<p>Error adding new offer: ' . mysql_error() . '</p>'; } ?> <p><a href="offer.php">Return to add another file</a></p> <?php else: // Allow the user to enter a new offer ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <p>Enter the new offer:</p> <label>Title: <input type="text" name="title" /></label><br /> <input type="submit" value="SUBMIT" /> </form> <?php endif; ?> Quote Link to comment Share on other sites More sharing options...
btherl Posted April 9, 2007 Share Posted April 9, 2007 There's also a stage 3, which is submission of the form from stage 2. Try printing out the filename at each stage to find out where it is disappearing. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.