Jump to content

Cant retrieve values from URL!! Please Help!


savio_mf

Recommended Posts

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.