bad_gui Posted August 12, 2007 Share Posted August 12, 2007 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 https://forums.phpfreaks.com/topic/64534-passing-variable-from-form/ Share on other sites More sharing options...
play_ Posted August 12, 2007 Share Posted August 12, 2007 Any errors? Link to comment https://forums.phpfreaks.com/topic/64534-passing-variable-from-form/#findComment-321702 Share on other sites More sharing options...
bad_gui Posted August 12, 2007 Author Share Posted August 12, 2007 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 https://forums.phpfreaks.com/topic/64534-passing-variable-from-form/#findComment-321725 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.