Jump to content

passing variable from form


bad_gui

Recommended Posts

I searched this forum and found pieces of the answer I need but I can't figure out

what I am doing wrong.

 

I'm modifying a journal article database to give uploaded pdf files a descriptive name

rather than sequential numbers.  The article description is pulled from a public database

and then passed to the local db along with the pdf file, which is "filename".

 



//fetch.php  excerpt

    $journal_abbr = str_replace ('.','',$journal_abbr);
    $journal_abbr = str_replace (' ','_',$journal_abbr);
    $pdfname = $journal_abbr . $volume . "p" . $pages . ".pdf";

<FORM ENCTYPE="application/x-www-form-urlencoded" ACTION="index.php?action=upload" METHOD="POST">
<INPUT TYPE="hidden" NAME="authors" VALUE="<? print htmlentities($names); ?>">
<INPUT TYPE="hidden" NAME="title" VALUE="<? print htmlentities($title); ?>">
<INPUT TYPE="hidden" NAME="journal" VALUE="<? print htmlentities($journal); ?>">
<INPUT TYPE="hidden" NAME="date1" VALUE="<? print htmlentities($date); ?>">
<INPUT TYPE="hidden" NAME="mesh" VALUE="<? print htmlentities($mesh); ?>">
<INPUT TYPE="hidden" NAME="abstract" VALUE="<? print isset($abstract) ? htmlentities($abstract) : "No abstract available."; ?>">
<INPUT TYPE="hidden" NAME="pdfname" VALUE="<? print htmlentities($pdfname); ?>">

//upload.php

    $file = $_POST['pdfname'];
    $date2 = date('Y-m-d');

if (move_uploaded_file ($_FILES['filename']['tmp_name'], "$library_path$file")) {

    $query = "INSERT INTO library (file,authors,title,journal,category,date1,date2,abstract)
    VALUES ('$file','$authors','$title','$journal','$category','$_POST[date1]','$date2',
            '$abstract')";
    $result = mysql_query ($query);

 

Thanks.

Link to comment
Share on other sites

No.  Below is the code I have to provide an error message but I just still see the form and file isn't in db

 

if (move_uploaded_file ($_FILES['filename']['tmp_name'], "$library_path$file")) {

    $query = "INSERT INTO library (file,authors,title,journal,category,date1,date2,abstract)
    VALUES ('$file','$authors','$title','$journal','$category','$_POST[date1]','$date2',
            '$abstract')";
    $result = mysql_query ($query);

    if (!$result) {
    die ("Could not upload into database: <br />" . mysql_error());
    }

 

 

 

I also tried this in the fetch script for passing the variable pdfname

 


<INPUT TYPE="hidden" NAME="pdfname" VALUE="<?php echo $pdfname; ?>">

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.